npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-otp-customized-form

v0.0.3

Published

react native otp form with yup validation

Downloads

6

Readme

React Native OTP Form

Overview

This npm package provides a customizable and easy-to-use React Native OTP (One-Time Password) input form. It leverages the react-hook-form library for form management and validation, offering a seamless experience for users entering OTP.

Installation

To install the package, use the following npm command:

npm install react-native-otp-form

Usage

import { OtpForm } from 'react-native-otp-form';

// Your React component
const MyComponent = () => {
  const handleOtpVerification = data => {
    // Handle OTP verification logic here
    console.log('Entered OTP:', data.otp);
  };

  return (
    <OtpForm
      onSubmit={handleOtpVerification}
      otpSize={6} // Set the desired OTP length
      emptyAlertMsg="Please enter the OTP"
      // Add other customization props as needed
    />
  );
};

export default MyComponent;

Props

onSubmit (Function, required)

A callback function that receives the entered OTP for further processing.

otpSize (Number, required)

The length of the OTP.

emptyAlertMsg (String, required)

The alert message to be displayed if the OTP is not entered.

focusOnVisit (Boolean, optional) | initial false

Whether to focus on the first input field when the component mounts.

autoComplete (Boolean, optional) | initial false

Whether to enable auto completion.

autoSubmit (Boolean, optional) | initial false

Whether to automatically submit the OTP.

focusColor (String, optional) | initial #0cc

The color of the focused input field.

notFocusColor (String, optional) | initial #ccc

The color of the unfocused input field.

focusBorderColor (String, optional) | initial #0e0e0e

The border color of the focused input field.

notFocusBorderColor (String, optional) | initial #fff

The border color of the unfocused input field.

textVisibility (Boolean, optional) | initial false

Whether to hide the input text.

selectionColor (String, optional) | initial #fff

The color of the cursor.

allStyles (Object, optional)

Custom styles to be applied to the component.

initial allStyles

allStyles = {
  otpHolderStyle:{
    flexDirection: 'row',
    marginHorizontal: 50,
    justifyContent: 'space-between',
    alignItems: 'center',
  },
  inputTextStyle: {
    fontSize: 26,
    color: 'white',
    flex: 1,
    textAlign: 'center',
    fontWeight: '600',
  },
  inputHolderStyle: {
    backgroundColor: '#fff',
    width: 50,
    height: 50,
    borderWidth: 1,
  },
  btnHolderStyle:{
    alignItems: 'center',
    justifyContent:'center',
    height: Platform.OS == 'android' ? 115 : 80,
    width: '100%',
  },
  btnStyle:{
    width: '50%',
    height: '40%',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#0fc',
    borderRadius: 10,
    borderWidth: 1,
    borderColor: 'blue',
  },
  btninputTextStyle:{
    fontSize: 20,
    color: 'black'
  }
}

Example

<OtpForm
  onSubmit={handleOtpVerification}
  otpSize={6}
  emptyAlertMsg="Please enter the OTP"
  focusOnVisit={true}
  autoComplete={false}
  autoSubmit={false}
  focusColor="#0cc"
  notFocusColor="#ccc"
  focusBorderColor="#0e0e0e"
  notFocusBorderColor="#fff"
  textVisibility={false}
  selectionColor="#fff"
  allStyles = {
    otpHolderStyle:{
      ...// for otp input container
    },
    inputTextStyle: {
      ...// for input text
    },
    inputHolderStyle: {
     ...// for single input holder
    },
    btnHolderStyle:{
      ...// for button container
    },
    btnStyle:{
      ...// for button
    },
    btninputTextStyle:{
      ...// for button text
    }
  }
/>

Feel free to customize the styles and behavior based on your application's requirements.

License

This package is licensed under the MIT License - see the LICENSE.md file for details.