OTP Input
FREEOne-time code field with slots, grouping, masking, paste and SMS autofill support.
Playground
Change the props and watch the component and its code update live.
Props
Code
import { OtpInput } from "@/components/ui/otp-input";
<OtpInput
groupSize={3}
onComplete={(code) => verify(code)}
/>Installation
Terminal
npx @bloxa/cli add otp-input
# or: npx shadcn@latest add @bloxa/otp-inputExamples
Verification code
Codes can be pasted and autofilled from SMS. onComplete fires when every slot is filled.
Enter the 6-digit code we sent you.
Grouped and masked
API reference
Every component also accepts the props of the element it renders.
OtpInput
| Prop | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | Number of characters. |
| value / defaultValue | string | — | Code value. |
| onValueChange | (value: string) => void | — | Called on every change. |
| onComplete | (value: string) => void | — | Called when every slot is filled. |
| pattern | "numeric" | "alphanumeric" | "numeric" | Accepted characters. |
| groupSize | number | — | Separator after every N slots. |
| mask | boolean | false | Hides characters behind dots. |
| size | "md" | "lg" | "md" | Slot size. |