OTP Input

Preview

Enter 123456 to verify.

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/otp-input

API Reference

length?
number

Number of slots. Default 6.

Default6
value?
string
Default—
defaultValue?
string
Default
onChange?
((value: string) => void)
Default—
onComplete?
((value: string) => void)

Fires once every slot is filled.

Default—
label?
string

Optional label rendered above the slots.

Default—
hint?
string

Helper text shown below the slots while idle.

Default—
successMessage?
string

Message shown below the slots when status is "success".

Default—
errorMessage?
string

Message shown below the slots when status is "error".

Default—
status?
"error" | "success" | "idle"

External validation feedback. "error" shakes, "success" draws a check.

Defaultidle
mask?
boolean

Render dots instead of the typed digits.

Defaultfalse
disabled?
boolean
Defaultfalse
autoFocus?
boolean
Defaultfalse
aria-label?
string

Accessible label for the underlying input.

DefaultOne-time passcode
className?
string
Default—
Also on React Native. Digits roll into slots, with SMS autofill.

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.

Updated