Input OTP
Accessible one-time password component with copy paste functionality.
About
Input OTP is built on top of input-otp by @guilherme_rodz.
Installation
Usage
<InputOtp maxLength={6}>
<InputOtp.Group>
<InputOtp.Slot index={0} />
<InputOtp.Slot index={1} />
<InputOtp.Slot index={2} />
</InputOtp.Group>
<InputOtp.Separator />
<InputOtp.Group>
<InputOtp.Slot index={3} />
<InputOtp.Slot index={4} />
<InputOtp.Slot index={5} />
</InputOtp.Group>
</InputOtp>Pattern
Use the pattern prop to define a custom pattern for the OTP input.
;<InputOTP maxLength={6} pattern={InputOtp.regexpOnlyDigitsAndChars}>
...
</InputOTP>Examples
Separator
Use the <InputOTPSeparator /> component to add a separator between input groups.
Disabled
Use the disabled prop to disable the input.
Controlled
Use the value and onChange props to control the input value.
Invalid
Use aria-invalid on the slots to show an error state.
Four Digits
A common pattern for PIN codes. This uses the pattern={REGEXP_ONLY_DIGITS} prop.
Alphanumeric
Use REGEXP_ONLY_DIGITS_AND_CHARS to accept both letters and numbers.
Form
API Reference
See the input-otp documentation for more information.