Input OTP
uistableInput OTP — from shadcn/ui (radix-nova style).
npx shadcn add @krawma/input-otpnpm: input-otp@^1.4.2, lucide-react@^1.22.0 · registry: @krawma/utils
Preview
States
focus-visibledisabledcomplete
Keyboard
BackspaceArrowLeftArrowRightDelete
Depends on
utils
Purpose
A segmented one-time-code / PIN input (built on input-otp) — one visible slot per
character, for verification codes and short numeric secrets.
Anatomy
InputOTP (owns the value + maxLength) › InputOTPGroup › InputOTPSlot (one per
digit), with InputOTPSeparator between groups.
Style
No variants — token-backed slots; the active slot shows a caret, filled slots the entered character.
Behavior & functionality
- Controlled (
value+onChange) with a fixedmaxLength; typing advances, Backspace moves back, paste distributes across slots. - Fire
onCompletewhen all slots are filled.
Accessibility
- Renders a single logical input under the hood — screen readers treat it as one
field; label it (
aria-label) and setinputMode/autoComplete="one-time-code". - Arrows / Backspace move between slots; the focused slot is indicated.
Do / Don't
- ✅ Set
autoComplete="one-time-code"and act ononComplete. - ❌ Don't use for general numeric entry — use
number-input.