OTP Input

One-time-code input with a gliding focus ring, digits that roll in per slot, error shake and a success check draw.

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.

6
value?
string
defaultValue?
string
onChange?
((value: string) => void)
onComplete?
((value: string) => void)

Fires once every slot is filled.

label?
string

Optional label rendered above the slots.

hint?
string

Helper text shown below the slots while idle.

successMessage?
string

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

errorMessage?
string

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

status?
"idle" | "error" | "success"

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

idle
mask?
boolean

Render dots instead of the typed digits.

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

Accessible label for the underlying input.

One-time passcode
className?
string

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