Usage
–
Pattern
Use the pattern prop to define a custom pattern for the OTP input. The
input-otp package exports REGEXP_ONLY_DIGITS (digits only),
REGEXP_ONLY_DIGITS_AND_CHARS (alphanumeric), and REGEXP_ONLY_CHARS (letters
only) for common use cases.
Disabled
1
2
3
–
4
5
6
Invalid state
Use aria-invalid on the InputOTPGroup to show an error state.
0
0
0
0
0
0
Props
InputOTP
| Prop | Type | Default | Description |
|---|---|---|---|
maxLength | number | - | Maximum number of characters |
value | string | - | Controlled value |
onChange | (value: string) => void | - | Callback when value changes |
pattern | RegExp | string | - | Pattern to validate input (e.g. REGEXP_ONLY_DIGITS) |
disabled | boolean | false | Whether the input is disabled |
containerClassName | string | - | Additional class for the container |
onComplete | (value: string) => void | - | Callback when all slots are filled |
InputOTPGroup
| Prop | Type | Default | Description |
|---|---|---|---|
aria-invalid | boolean | - | Marks the group as invalid for error styling |
InputOTPSlot
| Prop | Type | Default | Description |
|---|---|---|---|
index | number | - | Zero-based index of the slot |
API Reference
See the input-otp documentation for the full API and additional props.