Big news!Introducing Socket AI - ChatGPT-Powered Threat Analysis. Learn more
Socket
Log inDemoInstall

react-otp-field

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

react-otp-field

Customizable OTP Field component for the web built with React.js

    3.0.1latest
    GitHub

Version published
Maintainers
1
Weekly downloads
664
decreased by-35.78%

Weekly downloads

Changelog

Source

v3.0.1

Fixed dependencies

Readme

Source

react-otp-field

npm version npm npm

Customizable OTP Field component for the web built with React.js

Live Demo

Installation

npm install --save react-otp-field

Basic usage

import React, { useState } from 'react'; import OtpField from 'react-otp-field'; const App = () => { const [value, setValue] = useState(''); return ( <OtpField value={value} onChange={setValue} numInputs={6} onChangeRegex={/^([0-9]{0,})$/} autoFocus separator={<span>-</span>} isTypeNumber inputProps={{ className: 'otp-field__input', disabled: false }} /> ); };

API

NameTypeRequiredDefault valueDescription
valueStringtrue''The value of the OTP Field.
onChangeFunctiontrueconsole.logReturns OTP values typed in inputs.
numInputsNumberfalse4Number of inputs.
onChangeRegexRegExfalsenoneRegEx for single onChange.
labelTextStringfalse'Enter verification code'Aria-label attribute for inputs.
classNamesStringfalse'otp-field'Class names for OTP Field component.
autoCompleteStringfalse'off'AutoComplete props for first input.
autoFocusBooleanfalsefalseAutoFocus on first input.
separatorComponentfalsenoneSeparator between inputs.
isTypeNumberBooleanfalsefalseType number for inputs.
hasErrorBooleanfalsefalseError class 'otp-field--has-error' for otp-field component.
inputPropsObjectfalsenoneProps for inputs.

Development

Run the development server:
npm run dev

Keywords

FAQs

Last updated on 18 Nov 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc