Input OTP
The Input OTP (One-Time Password) component allows users to enter a code sent to their email or phone to verify their identity. This component is commonly used in two-factor authentication (2FA) and account recovery processes.
Usage
Examples
Invalid
Set the invalid prop to true to mark the input as invalid.
Disabled
Disable the input by setting the disabled prop to true.
A
B
1
2
Controlled Component
The input can be controlled by setting the value and onChange props. In the example below, we control InputOTP with a state and convert the values to uppercase on change.
Using the pattern Prop
Pass a regex to the pattern prop to only accept values of a certain pattern. For example, we can use a regex to only accept numbers:
Props
InputOTP
InputOTP is abstracted from input-otp's OTPInput. Please refer to the API references in this documentation.
| Prop | Type | Default |
|---|---|---|
maxLength | number | - |
defaultValue | string | - |
value | string | - |
onChange | function | - |
disabled | boolean | false |
invalid | boolean | false |
pattern | string | - |
InputOTPSlot
| Prop | Type | Default |
|---|---|---|
index | number | - |