Input OTP
One-time code boxes, 4 to 6. Typing moves to the next box, paste fills them all, and phones offer the code from the SMS.
Ritla scan of this preview: 40 of 41 checks3 breakpointsScanned Known misread of our own scanner: R023
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add input-otpAlso works with shadcn:
npx shadcn@latest add @ritla/input-otpDependencies it brings
@base-ui/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { InputOTP } from "@/components/ui/input-otp";<InputOTP label="Verification code" onValueComplete={verify} />Examples
API reference
InputOTP
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | None | Figma's Label. |
length | 4 | 5 | 6 | 6 | Figma's Show 5th and Show 6th. |
value / defaultValue | string | None | The code, in Western digits (0123456789). |
onValueChange | (value: string) => void | None | On every change. |
onValueComplete | (value: string) => void | None | Once every box is filled. |
autoSubmit | boolean | false | Submit the form when the code is complete. |
required / helperText / error / disabled / readOnly / name | … | None | As on Input Field. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| 0…9 | Types the digit and moves to the next box. |
| Backspace | Deletes and moves back a box. |
| ArrowLeftArrowRight | Between boxes, the same visual way in Arabic (the boxes read left to right). |
ARIA
- The first box takes the label; the others are “Digit 2 of 6”, in the page language.
autocomplete="one-time-code"andinputmode="numeric"for a number pad and the SMS suggestion.
Arabic and RTL notes
Mirrors
- The group starts at the inline start (the right), with the label.
Does not mirror
- The boxes read left to right: the first digit in the left box, as the code is written in the SMS.
- Numerals
- Typed Arabic-Indic (
٠١٢٣٤٥٦٧٨٩) and Persian digits are stored as Western digits (0123456789), so the code works from an Arabic keyboard. - Arabic typography
label-16, centered in each box.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)
- Forced-LTR container, or a bidi override, over Arabic content
- Unisolated bidi hazards: phones, emails, Latin tokens inside Arabic text
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space