OTP Box React

1.Installation

npm install --save otp-box-react
import { useState } from 'react';
import { OtpInput } from 'otp-box-react';

2.Usage

const [state, setState] = useState({ otp: new Array(6).fill('') });
const onChangeOtpHandler = (otpvalues, event, index) => {
  setState({ ...state, otp: otpvalues });
};
<OtpInput name="otp" className="otp-field" placeholder=" " otpvalue={state.otp} onChangeOtpHandler={onChangeOtpHandler} />

Hi there, I'm Anmol 👋

CodeSandbox    Discord    Linkedin    facebook    twitter    Instagram    slack    stackoverflow