A one-time code or PIN, one 44 px box per character, with paste and SMS autofill.
Input otp six digits
Install
npx shadcn add @syncrobotic/input-otp Also installs: input-otp, lucide-react, @syncrobotic/cn
Overview
Boxes for a short code typed one character at a time: a verification code, a pairing code, a PIN.
When to use
- Two-step sign-in and verification codes.
- Pairing a robot with a code from its screen.
- A short PIN to release a stop.
Use something else
- A password: Input with type password.
- A number with a range: Number field.
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Input otp with separator
Input otp pairing code
Input otp pin
Input otp filled
Input otp verify
Usage rules
- One real input underneath: paste and SMS autofill work.
- Say where the code was sent and when it expires.
- Show the error under the boxes, not in a toast.
Changelog
- 0.15.02026-11-19A full code no longer changes when you keep typing: input-otp kept the last character selected, so each key swapped the last box. Backspace, select-all and paste still edit. On a phone a long code's boxes give a few px each instead of overflowing.
- 0.10.02026-11-18Disabled keeps its words readable: a grey field (bg-muted, muted text) on controls with a surface, solid disabled ink on items and icons; no more 50 % opacity, which washes text out in sunlight.
- 0.9.02026-11-17New.