Input OTP
Enters a one-time code, one character per slot.
Installation
pnpm dlx shadcn@latest add @paneui/input-otpUsage
Composition
Examples
Accessibility
Label the first slot with the field label and give the rest aria-labels such as "Character 2 of 6". Pasting fills every slot; autoComplete is one-time-code so phones offer the code from a message.
API Reference
Built on the OTP Field primitive. Only the props this library adds or changes are listed; everything else passes through.
InputOTP
Also accepts every prop of OTPField.Root.
- length*
- number
- Number of slots.
- size= "default"
- "xs" | "sm" | "default" | "lg"
- Slot size (24 / 28 / 32 / 36px). Inside a sized
Fieldit follows the field. - onValueComplete
- (value: string) => void
- Called when every slot is filled.
| Prop | Type | Default | Description |
|---|---|---|---|
| length* | number | — | Number of slots. |
| size | "xs" | "sm" | "default" | "lg" | "default" | Slot size (24 / 28 / 32 / 36px). Inside a sized Field it follows the field. |
| onValueComplete | (value: string) => void | — | Called when every slot is filled. |
InputOTPSlot
Also accepts every prop of OTPField.Input.
- data-filled
- Present when the slot holds a character.
| Data attribute | Description |
|---|---|
| data-filled | Present when the slot holds a character. |