One-Time Password Field
stableA segmented input for OTP / PIN codes.
Basic usage
Examples
6-digit OTP
A six-cell OTP input with completion callback.
Four and six digit codes
Use segmented inputs for OTP, PIN and confirmation code flows.
Features
- Paste support.
- Numeric or alphanumeric.
Installation
bash
pnpm dlx structyl add one-time-password-fieldAPI Reference
OneTimePasswordField.Root
An OTP / PIN input.
| Prop | Type | Default |
|---|---|---|
| length | numberNumber of digits. | 6 |
| value | stringControlled value. | — |
| onValueChange | (value: string) => voidCalled when the value changes. | — |
| type | 'numeric' | 'alphanumeric'Allowed characters. | 'numeric' |
| mask | booleanMask the entered characters. | — |
| onComplete | (value: string) => voidCalled when all slots are filled. | — |
OneTimePasswordField.Input
A single digit slot.
| Prop | Type | Default |
|---|---|---|
| index | numberZero-based slot index. | — |