iOS | Android |
---|---|
iOS.mov
|
Android.mp4
|
yarn
:yarn add react-native-animated-otp-input
npm
:npm install react-native-animated-otp-input
import React from 'react'; import { Alert, StyleSheet, View } from 'react-native'; import OtpInput from 'react-native-animated-otp-input'; const OTPInput = () => { return ( <View style={styles.container}> <OtpInput otpCount={5} autoFocus={false} onCodeFilled={(code: number) => { Alert.alert('Notification', `OTP is ${code}`); }} onCodeChanged={(codes: number) => { console.log({ codes }); }} /> </View> ); }
Parameter | required | Description |
---|---|---|
pinCount | YES | Number of digits in the component, maxium is 6 |
containerStyle | NO | The style of the input field container |
inputStyle | NO | The style of the input field |
focusColor | NO | The color the input field which is focused |
autoFocus | NO | Auto activate the input and bring up the keyboard when component is loaded |
onCodeChanged | NO | Callback when the digits are changed |
onCodeFilled | NO | Callback when the last digit is entered |
editable | NO | Set editable for inputs |
rest | NO | The other text input props |
enteringAnimated | NO | The entering animation using reanimated layout |
exitingAnimated | NO | The exiting animation using reanimated layout |
rest | NO | The other text input props |