Input OTP
<InputOTP>TailwindCSS ModulesSeparate input slots for verification codes, with keyboard navigation, paste, and one-time-code autofill.
npx coloxo add input-otpimport { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from '@coloxo/ui';1. Variant Matrix
Enter a code, paste it from your clipboard, or use your device's one-time-code autofill.
| Format | Default | Filled | Disabled | Invalid |
|---|---|---|---|---|
| 4-digit code | 1 2 3 4 | 1 2 3 4 | 0 0 0 0 | |
| 6-digit code | 1 2 3 4 5 6 | 1 2 3 4 5 6 | 0 0 0 0 0 0 |
Six-digit verification code
Grouped with a separator
Four-digit PIN
Alphanumeric code
Disabled and invalid states
This code has expired. Request a new code.
2. Control heights (Sizes)
Choose small (36px), medium (44px), or large (52px) controls to match the surrounding form.
| Size | Height | Preview |
|---|---|---|
| sm | 36px | |
| md | 44px | |
| lg | 52px |
3. Interactive Props Configurator
Adjust the props to update the live preview and copy the generated code.
import { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from "@coloxo/ui";<InputOTP maxLength={6} size="md" aria-label="Verification code"> <InputOTPGroup> <InputOTPSlot index={0} /> <InputOTPSlot index={1} /> <InputOTPSlot index={2} /> <InputOTPSlot index={3} /> <InputOTPSlot index={4} /> <InputOTPSlot index={5} /> </InputOTPGroup></InputOTP>4. Dark theme
Input OTPs adapt their background surfaces, focus rings, and error colors seamlessly in dark mode.
5. Enterprise layout compositions
Use verification codes for workspace sign-in and sensitive account actions. These examples demonstrate local form state; connect your verification service to validate codes.
Verify your workspace sign-in
Enter the six-digit code from your authenticator app.
Confirm a sensitive action
Verify your identity before changing workspace security settings.
Use the latest code sent to your work email.
Accessibility
Uses one native input for screen readers and autofill. Associate a label with its id and describe errors with aria-describedby and aria-invalid. Keyboard selection, deletion, and pasting work through the native input. Use one label for the full code. Visual slots are handled by the input-otp primitive.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| maxLength | number | — | Required number of code characters. Slot indices must be below this value. |
| size | "sm" | "md" | "lg" | md | Slot control height: 36px, 44px, or 52px. |
| value / defaultValue | string | — | Controlled value or initial uncontrolled value. |
| onChange | (value: string) => void | — | Called when the code changes. |
| onComplete | (value: string) => void | — | Called when every character is filled. |
| pattern | string | REGEXP_ONLY_DIGITS | Allowed characters. Use REGEXP_ONLY_DIGITS_AND_CHARS for alphanumeric codes. |
| pasteTransformer | (text: string) => string | — | Normalize pasted codes, for example by removing hyphens. |
| disabled | boolean | false | Disables input interaction. |
| aria-invalid | boolean | — | Marks an invalid code and displays error borders. |
| containerClassName | string | — | Additional CSS class for the visual container. |
| index | number | — | InputOTPSlot only: zero-based character position. |