examples/input-otp-pin.tsx
1import { InputOtp } from "@/components/wensity/input-otp";23export function InputOtpPin() {4 return (5 <InputOtp6 label="Device PIN"7 mode="numeric"8 length={4}9 masked10 hint="Use your PIN."11 />12 );13}
An accessible one-time code field with alphanumeric, masked, and grouped variants for verification and two-factor flows.
Practical examples and common states for the same installable component.
Short numeric codes for device PINs and quick unlock flows.
Alphanumeric recovery codes with custom group separators.
Backup codes accept letters and numbers.
Show a confirmed code without the muted disabled treatment.
Hide entered characters for PIN-style entry.
Group digits with separators for easier scanning.
| Prop | Type | Default | Description |
|---|---|---|---|
length | number | 6 | Number of digit slots. |
mode | "numeric" | "alphanumeric" | "numeric" | Which characters are accepted, and the mobile keyboard shown. |
value | string | - | Controlled value. |
defaultValue | string | "" | Initial value when uncontrolled. |
onValueChange | (value: string) => void | - | Called on every change to the value. |
onComplete | (value: string) => void | - | Fires once every slot is filled by the user. Requires autoSubmit. |
onFilled | (value: string) => void | - | Fires when every slot is filled, without submitting. Never fires on mount. |
autoSubmit | boolean | false | Calls onComplete as soon as the last slot is filled. |
masked | boolean | false | Hides entered characters, for codes treated as secrets. |
groups | number[] | - | Slot grouping for separated layouts. Must sum to length — [3, 3] renders 123 . 456. |
separator | React.ReactNode | "•" | Node rendered between digit groups. |
status | "default" | "error" | "success" | - | Drives the success and error visuals and which message is shown. |
error | React.ReactNode | - | Message shown when status is error. |
success | React.ReactNode | - | Message shown when status is success. |
loading | boolean | false | Verifying state: locks input, sets aria-busy, and pulses the slots. |
loadingMessage | React.ReactNode | "Verifying…" | Screen-reader and helper copy while loading is true. |
readOnly | boolean | false | Locks input without the muted disabled styling. Useful after submit. |
inputSize | "sm" | "md" | "lg" | "md" | Slot size and text size. |
fullWidth | boolean | true | Stretches the slot row to fill its container. |