Installation
About
Input OTP is built on top of input-otp by @guilherme_rodz.Usage
Component API
InputOTP
The root OTP input component. Props:maxLength- Maximum number of characters (required)value- Controlled valueonChange- Callback when value changespattern- Regex pattern for validationdisabled- Disable the inputcontainerClassName- Additional classes for container
InputOTPGroup
Groups OTP slots together.InputOTPSlot
An individual OTP character slot. Props:index- Slot index (required)aria-invalid- Mark as invalid
InputOTPSeparator
Visual separator between groups.Examples
Basic
A simple 6-digit OTP input:Pattern
Use thepattern prop to define validation:
Separator
Add separators between groups:Controlled
Control the input value:Disabled
Disable the OTP input:Invalid State
Show an error state:Four Digits
A 4-digit PIN input:Form
Use in a form with React Hook Form:Accessibility
- Built on input-otp for full accessibility
- Keyboard navigation support
- Copy/paste functionality
- Screen reader compatible
- Focus management
- Auto-advance on input