Preview

-

Installation

<> import.ts
import { InputOTP } from "@/components/ui/input-otp"

Code

<> component.tsx
import { InputOTP } from "@/components/ui/input-otp"

<InputOTP />

API Reference

InputOTP

One-time passcode input with grouping, paste, and keyboard navigation.

<> import.ts
import { InputOTP, InputOTPPresets } from "@/components/ui/input-otp"

Props

PropTypeDefaultDescription
length
number6Number of digits
value
stringControlled OTP value
onChange
(value: string) => voidCalled with OTP on change
className
string""Additional CSS classes
size
"sm" | "md" | "lg""md"Input size
disabled
booleanfalseDisable inputs
autoFocus
booleantrueFocus first input on mount

Presets

small

4 digits, small size

medium

6 digits, medium size

large

8 digits, large size