Component
A one-time code input: single-character slots that fill left to right, accept paste and SMS autofill, and submit as one value.
View component changelogpreview
Enter the 6-digit code
- Slots fill left to right; focusing past the first empty slot moves there
- Paste or SMS autofill spreads a full code across the slots
- Numeric, alphabetic or alphanumeric validation, and password masking
- Submits as one value through a hidden input, with optional auto-submit
Import all parts of the component and piece them together
Holds the code and renders a group of slots plus a hidden input for forms.
| Prop | Type | Default |
|---|---|---|
value | string | -- |
defaultValue | string | "" |
onValueChange | (value: string) => void | -- |
length | number | 6 |
validationType | 'numeric' | 'alpha' | 'alphanumeric' | 'none' | 'numeric' |
type | 'text' | 'password' | 'text' |
onValueComplete | (value: string) => void | -- |
autoSubmit | boolean | false |
name | string | -- |
disabled | boolean | false |
readOnly | boolean | false |
required | boolean | false |
mask | boolean | false |
normalizeValue | (value) => string | -- |
onValueInvalid | (value, { rejected }) => void | -- |
inputMode | string | numeric or text |
autoComplete | string | "one-time-code" |
form | string | -- |
One character slot. Render one per character, in order. The first offers autocomplete="one-time-code".
| Prop | Type | Default |
|---|---|---|
aria-label | string | "Character n of length" |
asChild | boolean | false |
| Shortcut | Description |
|---|---|
ArrowLeft | Moves to the previous slot. |
ArrowRight | Moves to the next filled slot. |
Home | Moves to the first slot. |
End | Moves to the last filled slot. |
Tab | Moves focus in and out of the slots. |
| Reference | What Rad UI follows |
|---|---|
Each slot is a text input named "Character n of length" inside a labelled group. |