easeUI

OTP Input

One box per digit for a verification code, with paste and SMS autofill support and a shake for a wrong code.

Try 2 4 6 8 1 0.

Verification code

Installation

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

API reference

PropTypeDefaultDescription
length?number6How many digits. Default 6.
value?string-Controlled value.
defaultValue?stringStarting value when uncontrolled. Default "".
onChange?((value: string) => void)--
onComplete?((value: string) => void)-Called once every box has a digit, before onVerify runs.
onVerify?((value: string) => any)-Runs once every box has a digit. Return (or resolve) true or false and the input shows a spinner below the boxes while it waits, then colors itself green or red from the result on its own. Leave it out to keep driving invalid/success yourself.
invalid?booleanfalseShakes the boxes once and switches the ring to the destructive color. Ignored while onVerify is set.
success?booleanfalseSwitches the ring to the success color and shows a check below the boxes. Ignored while onVerify is set.
disabled?booleanfalse-
name?string-Name for a hidden input, so the code submits with a plain HTML form.
className?string--

Updated