OTP Input
Boxes for entering a one-time code sent by SMS or email.
- Status
- ReadyBuild day 19 of 21
- Code
- In React
- Role
- Form
Usage
This demo is live, and the code below it is the same code, imports included. The component lives in src/ui of this repository and is not published to npm yet.
Try 482719. Resend code in 00:45
Pastes as editable layers. Shadows are not exported.
import { useState } from "react";
import { OtpInput } from "@/ui";
export default function OtpDemo() {
const [code, setCode] = useState<string>("");
return (
<OtpInput
label="Verification code"
value={code}
onChange={setCode}
onComplete={(v: string) => console.log("submit", v)}
hint="Resend code in 00:45"
/>
);
}Variants and states
Every specimen is the real component from src/ui, held in one state.
Incorrect OTP. 2 attempts left.
Incorrect OTP. 2 attempts left.
Incorrect OTP. 2 attempts left.
Pastes as editable layers. Shadows are not exported.
Props
- label
- string · default none
- Required. Names the group.
- length
- 4 | 6 · default 6
- Number of boxes.
- value, onChange
- string, (value) => void · default none
- Digits only.
- onComplete
- (value) => void · default none
- Called once every box is filled. Use it to submit.
- size
- "sm" | "md" | "lg" · default "md"
- hint, error
- string · default none
- Helper or error line.
- disabled
- boolean · default none
Figma to code
Figma properties by their exact names from Naming, and the React prop that carries each one. The table covers the shared properties that bear on this component; the Figma file decides which of them its component exposes. None means there is no prop for it yet.
- 🔀 Count
- length
- 4 or 6 Digit.
- 📐 Size
- size
- OTP Cell size.
- 🎯 State
- value, error, disabled
- Focused is the browser.
- Show Helper Text, Helper Text
- hint
- Pass to show.
Accessibility
What the code in src/ui does today, and what it leaves to you.
Keyboard
- Typing moves to the next box, Backspace goes back, arrows move, and pasting a code fills every box.
Screen readers
- A group named by the label. Each box is named Digit 1 of 6 and so on. The first box has autocomplete=one-time-code.
What you still need to do
- Tell people how long until they can resend, and do not clear the boxes on error without saying so.
When to use
Verification steps. Accept a pasted code and move focus between boxes automatically.
Do and don't
Do
- Set autocomplete="one-time-code" so phones can fill it.
- Show where the code was sent and a way to resend it.
Don't
- Block paste.
- Clear the whole code when one digit is wrong.
Related
4 of 16 other atoms, same role and ready ones first.
- CheckboxLets users select one or more options from a set.Ready
- PIN InputMasked boxes for entering a secret PIN.Ready
- Radio ButtonA single option that belongs to a set where only one can be chosen.Ready
- SliderPicks a value from a continuous range by dragging.Ready
Status reflects the component tracker snapshot of 29 October 2026.