1.0.0 • Published 4 years ago

@daoduythanh/react-native-otpinput v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

React Native Otp Input

styled with prettier License: MIT

A cross-platform and simple Otp Input component for React Native.

  • Handle Input suggestion on IOS (requires React Native 0.58+ and iOS 12 or above)
  • Auto fill when copy code on Android.
  • Fully-typed with Typescript

Installation

$ npm install -S react-native-otpinput

or

$ yarn add react-native-otpinput

Usage

import React, { useState } from 'react';
import { View } from 'react-native';
import { OtpInput } from 'react-native-otpinput';

const App: React.FC<{}> = () => {
  const [code, setCode] = useState('');

  return (
    <View>
      <OtpInput code={code} onCodeChanged={setCode} pinCount={4} />
    </View>
  );
};

Props

NameTypeDefaultDescription
autoFocusOnLoadbooleanfalseauto focus the 1st input and show keyboard on load
codestringREQUIREDthe value of the input
digitInputHighlightStyleobjectnullthe style of focused input
digitInputStyleobjectnullthe style of all inputs
onCodeChangedfunctionREQUIREDcalled when the code is changed
onCodeFilledfunctionnullcalled when the last digit is filled
pinCountnumberREQUIREDthe number of digit in OTP code
secureTextEntrybooleanfalseif true, the text input obscures the text entered so that sensitive text like passwords stay secure
styleobjectnullcustom container style

Acknowledgement

This library is created based on @twotalltotems/react-native-otp-input