Gathering detailed insights and metrics for @syeda_mehwish/react-native-otp-entry
Gathering detailed insights and metrics for @syeda_mehwish/react-native-otp-entry
Simple and fully modifiable OTP Input Component for React Native
npm install @syeda_mehwish/react-native-otp-entry
Typescript
Module System
Node Version
NPM Version
73.9
Supply Chain
98.5
Quality
76.9
Maintenance
100
Vulnerability
100
License
TypeScript (99.61%)
JavaScript (0.39%)
Total Downloads
938
Last Day
2
Last Week
10
Last Month
52
Last Year
938
295 Stars
142 Commits
33 Forks
2 Watching
3 Branches
14 Contributors
Latest Version
0.0.2
Package Id
@syeda_mehwish/react-native-otp-entry@0.0.2
Unpacked Size
276.02 kB
Size
203.88 kB
File Count
48
NPM Version
10.2.4
Node Version
21.6.2
Publised On
04 Apr 2024
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
66.7%
10
Compared to previous week
Last month
-40.2%
52
Compared to previous month
Last year
0%
938
Compared to previous year
react-native-otp-entry
is a simple and highly customizable React Native component for entering OTP (One-Time Password). It provides an intuitive and user-friendly interface for inputting one-time passwords in your React Native applications.
Install react-native-otp-entry
using npm or yarn:
1npm install react-native-otp-entry 2 3# or 4 5yarn add react-native-otp-entry
Import the OtpInput
component from react-native-otp-entry
:
1import { OtpInput } from "react-native-otp-entry";
Render the OtpInput
component in your screen/component:
1<OtpInput numberOfDigits={6} onTextChange={(text) => console.log(text)} />
Customize the styling as per your requirements:
1<OtpInput 2 numberOfDigits={6} 3 focusColor="green" 4 focusStickBlinkingDuration={500} 5 onTextChange={(text) => console.log(text)} 6 onFilled={(text) => console.log(`OTP is ${text}`)} 7 theme={{ 8 containerStyle: styles.container, 9 inputsContainerStyle: styles.inputsContainer, 10 pinCodeContainerStyle: styles.pinCodeContainer, 11 pinCodeTextStyle: styles.pinCodeText, 12 focusStickStyle: styles.focusStick, 13 focusedPinCodeContainerStyle: styles.activePinCodeContainer, 14 }} 15/>
The react-native-otp-entry
component accepts the following props:
Prop | Type | Description |
---|---|---|
numberOfDigits | number | The number of digits to be displayed in the OTP entry. |
autoFocus | boolean | Set autofocus. |
focusColor | ColorValue | The color of the input field border and stick when it is focused. |
onTextChange | (text: string) => void | A callback function is invoked when the OTP text changes. It receives the updated text as an argument. |
onFilled | (text: string) => void | A callback function is invoked when the OTP input is fully filled. It receives a full otp code as an argument. |
hideStick | boolean | Hide cursor of the focused input. |
theme | Theme | Custom styles for each element. |
focusStickBlinkingDuration | number | The duration (in milliseconds) for the focus stick to blink. |
autoComplete | string | passed to underlying TextInput (see: https://reactnative.dev/docs/textinput#autocomplete) |
Theme | Type | Description |
---|---|---|
containerStyle | ViewStyle | Custom styles for the root View . |
inputsContainerStyle | ViewStyle | Custom styles for the container that holds the input fields. |
pinCodeContainerStyle | ViewStyle | Custom styles for the container that wraps each individual digit in the OTP entry. |
pinCodeTextStyle | TextStyle | Custom styles for the text within each individual digit in the OTP entry. |
focusStickStyle | ViewStyle | Custom styles for the focus stick, which indicates the focused input field. |
focusedPinCodeContainerStyle | ViewStyle | Custom styles for the input field when it is focused. |
filledPinCodeContainerStyle | ViewStyle | Custom styles for the input field when it has a value. |
Note: The ViewStyle
and TextStyle
types are imported from react-native
and represent the style objects used in React Native for views and text, respectively.
The react-native-otp-entry
component exposes these functions with ref
:
Prop | Type | Description |
---|---|---|
clear | () => void; | Clears the value of the OTP input. |
focus | () => void; | Focus of the OTP input. |
setValue | (value: string) => void; | Sets the value of the OTP input. |
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to open issues or submit pull requests.
If you find a bug or have any feature requests, please open an issue :)
No vulnerabilities found.
No security vulnerabilities found.