Gathering detailed insights and metrics for react18-input-otp
Gathering detailed insights and metrics for react18-input-otp
Gathering detailed insights and metrics for react18-input-otp
Gathering detailed insights and metrics for react18-input-otp
A fully customizable, one-time password (OTP) and phone number with separator input component for the web built with React.
npm install react18-input-otp
Typescript
Module System
Node Version
NPM Version
90
Supply Chain
91.6
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (83.76%)
CSS (13.72%)
HTML (2.52%)
Total Downloads
2,152,304
Last Day
3,586
Last Week
20,089
Last Month
85,493
Last Year
1,094,973
MIT License
39 Stars
25 Commits
5 Forks
1 Watchers
4 Branches
1 Contributors
Updated on Dec 10, 2024
Minified
Minified + Gzipped
Latest Version
1.1.4
Package Id
react18-input-otp@1.1.4
Unpacked Size
30.65 kB
Size
8.80 kB
File Count
5
NPM Version
9.5.1
Node Version
19.8.1
Published on
Jul 10, 2023
Cumulative downloads
Total Downloads
Last Day
50.5%
3,586
Compared to previous day
Last Week
4.7%
20,089
Compared to previous week
Last Month
-6.1%
85,493
Compared to previous month
Last Year
33.4%
1,094,973
Compared to previous year
24
A fully customizable, one-time password (OTP) and phone number with separator input component for the web built with React. Tested on Web, Android, and iOS. This package supports all react versions.
npm install --save react18-input-otp
1import React, { Component } from 'react'; 2import OtpInput from 'react18-input-otp'; 3 4export default class App extends Component { 5 state = { otp: '' }; 6 7 handleChange = (otp) => this.setState({ otp }); 8 9 render() { 10 return <OtpInput value={this.state.otp} onChange={this.handleChange} numInputs={6} separator={<span>-</span>} />; 11 } 12}
1import React, { useState } from 'react'; 2import OtpInput from 'react18-input-otp'; 3export default function ReactOtpInput() { 4 const [otp, setOtp] = useState(''); 5 const handleChange = (enteredOtp) => { 6 setOtp(enteredOtp); 7 }; 8 return <OtpInput value={otp} onChange={handleChange} numInputs={6} separator={<span>-</span>} />; 9}
Name | Type | Required | Default | Description |
---|---|---|---|---|
id | string | false | none | Provide unique id for your OTP input. |
numInputs | number | true | 4 | Number of OTP inputs to be rendered. |
onChange | function | true | console.log | Returns OTP code typed in inputs. |
onSubmit | function | false | console.log | Returns OTP code on submit. This allows to submit the OTP on enter key too. |
value | string / number | true | '' | The value of the OTP passed into the component. |
placeholder | string | false | none | Specify an expected value of each input. The length of this string should be equal to numInputs . |
separator | component | false | none | Provide a custom separator between inputs by passing a component. For instance, <span>-</span> would add - between each input. |
separateAfter | number | false | 1 | Provide the count to set the separater after every input. For instance, 3 would add - after every third input. |
autoComplete | string | false | off | Provide the autocomplete feature for the input. Now, supports one-time-code as autoComplete. |
ariaLabelOverride | string | false | none | Provide the custom arialabel for the input. |
containerStyle | style (object) / className (string) | false | none | Style applied or class passed to container of inputs. |
inputStyle | style (object) / className (string) | false | none | Style applied or class passed to each input. |
focusStyle | style (object) / className (string) | false | none | Style applied or class passed to inputs on focus. |
isDisabled | boolean | false | false | Disables all the inputs. |
disabledStyle | style (object) / className (string) | false | none | Style applied or class passed to each input when disabled. |
hasErrored | boolean | false | false | Indicates there is an error in the inputs. |
errorStyle | style (object) / className (string) | false | none | Style applied or class passed to each input when errored. |
isSuccessed | boolean | false | false | Indicates there is success with the inputs.. |
successStyle | style (object) / className (string) | false | none | Style applied or class passed to each input when success. |
shouldAutoFocus | boolean | false | false | Auto focuses input on initial page load. |
isInputNum | boolean | false | false | Restrict input to only numbers. |
isInputSecure | boolean | false | false | Masks input characters. |
data-cy | string | false | - | Test attribute passed to the inputs. |
data-testid | string | false | - | Test attribute passed to the inputs. |
custom-test-id | string | false | - | Custom test attribute passed to the inputs. |
custom-test-attr | string | false | - | Custom test attribute passed to the inputs. |
inputProps | InputHTMLAttributes | InputHTMLAttributes[] | false | - | Custom input props. |
npm run dev
Feel free to open issues and pull requests!
Special Thanks to devfolioco. This project is build on top of react-otp-input.
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
No security vulnerabilities found.