Haedong
045

Input OTP

Form

value: —

Customize

Length
State

Code

<InputOtp onComplete={verify} aria-label="Code" />

Install

npx shadcn@latest add https://components.haedong.dev/r/input-otp.json

Props

Extends the native input props (minus value/onChange/type/maxLength). One real input sits invisibly over the cells, so the numeric keyboard, autocomplete="one-time-code", paste, form submission and screen readers all work as for a plain field; give it aria-label or put it in a Field. aria-invalid dashes every cell.

PropTypeDescription
lengthnumberNumber of cells. Defaults to 6.
value / defaultValuestringControlled / uncontrolled value.
onValueChange(value: string) => voidEvery change.
onComplete(value: string) => voidOnce, when all cells are filled.
patternRegExpAccepted characters. Defaults to digits.