2.0.6 • Published 10 months ago

rn-otp-inputs v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

rn-otp-inputs TS

rn-otp-inputs is a tiny Javascript/typescripts library which provides an elegant UI for the end user to input one time passcode (OTP). It handles autocomplete functionality and it display remaining time for OTP. It also features a carefully crafted flow to handle edge cases for volatile user gestures. We provide default UI, but you can always customize the appearance as you like.

ScreenShot

Ios

Android

Installation

npm install --save rn-otp-inputs

or

yarn add rn-otp-inputs

PeerDependencies

NOTES:

This packgae will support react@^17.0.0, react@^18.0.0,react-native@^0.68.0 to react-native@^0.75.3, . Make sure you have install respective viersion.

npm install --save react@17.0.0 react-native@latest

or

yarn add react@17.0.0 react-native@latest

Basic Usage

import RnOtpInputs from 'rn-otp-inputs';

...

<RnOtpInputs  pinCount={4} onSubmit={()=>{}} />

More Advanced Usage

import  RnOtpInputs  from  'rn-otp-inputs';

...
const  [value,  setValue]  =  useState('');
...
<RnOtpInputs
  pinCount={4}
  mode='rectangle'
  onSubmit={()=>{}}
  autoSubmit={true}
  borderRadius={6}
  borderWidth={1}
  borderColor='#A768F1'
  bgColor='#D9E3F6'
  textColor='#000000'
  onChageValue={setValue}
  keyboardType='number-pad'
  buttonTitle='Verify & Proceed'
  Minute={1}
  Second={0}
  onlyResendOtp={false}
  onResendClick={()=>{}}
/>

Parameters

ParameterRequiredTypeDefaultDescription
pinCountYesNumber4Number of digits in the component , range is 4-6.
onSubmitYesFunction()=>{}Callback when Submit Button is Click.
modeNoStringrectanglemode can be rectangle, flat or circle.
autoSubmitNoBooleanfalseCallback when the digits are filled . Note : If value is true then we can get entered value from onSubmit. e.g.onSubmit={(value)=>{console.log(value)}}
borderRadiusNoNumber6Change Border Radius of input field. Note :borderRadius will apply when mode is reactangle
borderColorNoString#A768F1Change Border Color of input field.
borderWidthNoNumber1Change Border Width of input field.
bgColorNoString#D9E3F6Change Background Color of input field.
textColorNoString#000000Change the style of the input Text.
onChageValueNoFunction()=>{}Callback when the digits are Changed.
keyboardTypeNoStringnumber-padKeyboard type.
buttonTitleNoStringVerify & ProceedButton Title .
MinuteNoNumber1Remaining Time in minute.
SecondNoNumber0Remaining Time in Second.
onlyResendOtpNoBooleanfalseIf value is true Remaining time will not Display, Only Resend Otp Button will display.
onResendClickNoFunction()=>{}Callback when the Resend Button clicked.
buttonStyleNoobject{{flex: 1,height: scale(40)}}Change the style of the Button.
buttonTitleStyleNoobject{{fontSize: scale(15),color: "#FFFFFF"}}Change the style of the Button Title.
resendButtonStyleNoobject{{fontSize: scale(15), color: "#404B69"}}Change the style of the Resend Button.
inputHeightAndWidthNoNumber50Height and width of input field.
isErrorNoBooleanfalseTo Display Error Message.
errorMsgNoStringInvalid OTP.Change the Error Message.
errorMsgStyleNoobject{{fontSize: scale(12),color: "red"}}Change the style of Error Message.
isButtonDisplayNoBooleantrueIf you don't want to use Button, then you have to pass false . NOTE If the value is true and you don't want to use any button for submit , then you have to use autoSubmit props.
isResendOtpDisplayNoBooleantrueIf you don't want to use Resend OTP Button, then you have to pass false.

Contributing

Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.

Author

jayanta7381

Jayanta Garu

License

MIT

2.0.3

10 months ago

2.0.2

10 months ago

2.0.5

10 months ago

2.0.4

10 months ago

2.0.6

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago