OTP Input
A fully accessible one-time password input component with keyboard navigation, paste support, and customizable layouts.
Install Dependencies
npx quickcode-ui add OtpInputExamples
Basic OTP Input
Enter the 6-digit code sent to your device
4-Digit PIN
Enter your 4-digit PIN
Controlled with State
Current value: (empty)
Alphanumeric Pattern
Enter alphanumeric code (A-Z, 0-9)
Props
OtpInput
| Prop | Type | Default | Description |
|---|---|---|---|
maxLength | number | — | Maximum number of characters (required) |
value | string | — | Controlled value |
onChange | (value: string) => void | — | Called when the value changes |
disabled | boolean | false | Disables all input slots |
pattern | RegExp | /^[0-9]$/ | RegEx pattern for character validation |
containerClassName | string | — | Additional CSS classes for the container |
className | string | — | Additional CSS classes |
OtpInput.Group
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes |
children | React.ReactNode | — | OtpInput.Slot components |
OtpInput.Slot
| Prop | Type | Default | Description |
|---|---|---|---|
index | number | — | Position index of the slot (required) |
className | string | — | Additional CSS classes |
OtpInput.Separator
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes |
children | React.ReactNode | — | Custom separator content (defaults to dash icon) |
Last updated on