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-input-fields

v1.0.5

Published

React Native Component for OTP Input Fields.

Downloads

7

Readme

react-native-otp-input-fields

This is a component for OTP Input fields.

Installation

npm i react-native-otp-input-fields

NOTE: This package uses react-native-reanimated under the hood for input field animation. If you are using React Navigation for navigation purpose in your app, then you don't have to do anything. Otherwise, Follow the installation process of React Native Reanimated.

Usage

Below are some examples to use this package

Basic Usage

import OTPInput from "react-native-otp-input-fields";

const [OTP, SetOTP] = useState("");
// Maintain a state variable

// Use it like this
<OTPInput onChangeText={SetOTP} value={OTP} />;

Password Secure Usage

import OTPInput from "react-native-otp-input-fields";

const [OTP, SetOTP] = useState("");
// Maintain a state variable

// Use it like this
<OTPInput onChangeText={SetOTP} value={OTP} secureTextEntry={true} />;

Change Colors and other styles

import OTPInput from "react-native-otp-input-fields";

const [OTP, SetOTP] = useState("");
// Maintain a state variable

// Use it like this
<OTPInput
  onChangeText={SetOTP}
  value={OTP}
  borderColor="orange"
  boxBackgroundColor="dodgerblue"
  cursorColor="orange"
  digitColor="white"
/>;

Apply Elevation and Border Radius etc.

import OTPInput from "react-native-otp-input-fields";

const [OTP, SetOTP] = useState("");
// Maintain a state variable

// Use it like this
<OTPInput
  onChangeText={SetOTP}
  value={OTP}
  boxBorderRadius={50}
  onlyBorderBottom={false}
  boxElevation={10}
/>;

Parameters

Basic Parameters

| Parameter | required | Default | Description | | ----------------- | -------- | ----------- | ---------------------------------------------------------------------------------------- | | value | YES | | Maintain a state in parent component and use it as a controlled input | | onChangeText | YES | | the onChangeText function to update the state in parent component | | count | NO | 6 | Number of digits in the OTP | | autoFocus | NO | false | Whether to autofocus the first field | | removeOnBackspace | NO | true | Whether to clear the previous input while pressing the backspace button on a input field | | onSubmitEditing | NO | | function to execute when user presses the done button on keyboard | | containerWidth | NO | screenWidth | Width of the Input Field Container | | boxHeight | NO | 60 | Height of each input field | | margin | NO | 5 | margin between each input field |

Customization

| Parameter | required | Default | Description | | ------------------ | -------- | ------- | ------------------------------------------------------------------ | | secureTextEntry | NO | false | Mask the text input as password field or not | | allowDigitsOnly | NO | false | Allow only digits to be entered in the text input | | digitFontSize | NO | 25 | font size of the text inside input field | | animateDuration | NO | 300ms | Duration for the animation to complete when input field is focused | | cursorColor | NO | black | color of the blinking cursor | | digitColor | NO | black | color of the digit inside the field | | onlyBorderBottom | NO | true | whether to show border around whole box or just the border bottom | | keyboardType | NO | true | type of Keyboard from KeyboardTypeOptions in react-native | | borderBottomWidth | NO | 3 | width for the border bottom of box | | borderColor | NO | black | color for the border of box | | boxElevation | NO | 6 | elevation for the input field box | | maxLength | NO | 1 | Max length of each input field | | inputStyle | NO | | styles for the TextInput component | | boxHeight | NO | 60 | height of each input field | | boxBorderRadius | NO | 0 | border Radius of input field | | boxContainerStyle | NO | | styles for the input containers | | containerStyle | NO | | styles for the whole input box container (outer) | | boxBackgroundColor | NO | white | backround Color of the input fields |