Overview
Input OTP provides individual digit slots for entering one-time passwords or verification codes. It handles auto-focus progression between slots, clipboard paste, and backspace deletion automatically.Installation
Usage
Variants
Basic (6 digits)
With Separator (3 + 3)
—
Error State
Invalid code. Please try again.
Controlled with Pattern Validation
API Reference
InputOTP
InputOTPSlot
Accessibility
- Each slot renders as a single-character
<input>withinputmode="numeric"andautocomplete="one-time-code" - Focus automatically advances to the next slot on input and retreats on Backspace
- Pasting a full code fills all slots in one action
- The group container uses
role="group"with anaria-labeldescribing the purpose (e.g. “One-time password”) - Error state sets
aria-invalid="true"on all slots
Do’s & Don’ts
Do
- Use
onCompleteto trigger verification automatically when all slots are filled - Support clipboard paste — don’t block
pasteevents - Show a resend link with a cooldown timer below the input
- Use 6 digits for standard OTP, 4 for simpler PIN inputs
Don't
- Don’t use a regular
<Input>for OTP — users expect the slot-by-slot pattern - Don’t block numeric keyboard on mobile — use
inputmode="numeric" - Don’t auto-submit without giving the user a chance to correct mistakes
- Don’t hide the entered digits — OTP codes are not passwords