Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

OTPInput

  • Needs review
  • WCAG 2.2 evidence
  • RTL

A one-time code field: a label, a row of OTPCells, and a footer with the helper, status or error and an optional resend action. React Aria has no OTP primitive, so it is a React Aria TextField whose single real <input> lies under the cells: screen readers meet one labelled field with one value (WCAG 1.3.1, 4.1.2), and there is one tab stop. - Typing fills the next cell; Backspace clears the previous one; Arrow Left / Right, Home and End (Arrow Up / Down too) move between cells, and a digit typed on a filled cell replaces it. A click on a cell moves there (WCAG 2.1.1). - Paste of the whole code ("123 456" or "123-456" too) fills every cell; autoComplete="one-time-code" lets the phone offer the SMS code, and password managers can fill it (WCAG 3.3.7, 3.3.8). inputMode="numeric" shows the number pad. - Errors show an icon and text and, like the Verifying and Verified status, are announced politely (WCAG 1.4.1, 3.3.1, 4.1.3). - The focused cell draws the brand stroke and halo (2.4.7). Digits stay left-to-right in right-to-left layouts (rule G4). Consumer duties: label, helper and error wording; verifying the code (onComplete never submits a form); the countdown and re-enabling resend; explaining a disabled (locked) field in description.

import { OTPInput } from "@nexera-ui/react";
Loading example…
7
examples
36
props
8
live controls
1
platform
16
WCAG criteria
1
block uses it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
size
isMasked
description
status
isDisabled
isReadOnly
isRequired
isInvalid
Generated code
import { OTPInput } from "@nexera-ui/react";

<OTPInput />

Examples 6

The same examples as Storybook, rendered live. Open Code to copy one.

Lengths and sizes

Figma Length and Size. A six-cell code shows the separator after the third cell; cells wrap only when the container is narrower than the code.

Loading example…

States

Semantic states: isInvalid with errorMessage and an actionable onResend, status="verifying" and status="success", isDisabled with the reason in description, and isMasked.

Loading example…

Verification flow

A realistic flow: onComplete starts the verification in place (no form submission), the status line announces "Verifying" and then "Verified" or the error. Paste "123456" (or "123-456") to fill every cell at once; the correct code is 246810.

Loading example…

Long label

Long labels and helper texts wrap; at 320 px a six-cell lg code wraps its cells instead of scrolling (WCAG 1.4.10).

Loading example…

Right to left

Right-to-left: label and footer mirror; the digits stay left-to-right because a code is read in order (rule G4).

Loading example…

With verify button

Buttons that a page puts next to the field: verification is never automatic on submit, so a Verify button is common.

Loading example…

Props 36

Press "Try it" on a card to load that prop into the playground.

36 props shown

lengthNexera
4 | 6

Number of cells. The value never gets longer; a pasted or autofilled code is cut to this length.

Default 4
sizeNexera
"md" | "lg"

Cell size: 48 px cells 8 px apart, or 40 px cells 6 px apart.

Default lg
isMaskedNexera
boolean

Show dots instead of digits. The input becomes a password field, so screen readers do not speak the digits either; the progress text still says how many are entered.

Default false
descriptionNexera
ReactNode

Helper text under the cells, for example where the code was sent. Linked with aria-describedby. Hidden while an error or a status is shown, as in Figma. In the disabled state it carries the reason ("Too many attempts. Try again in 10:00"), which Figma keeps in text/muted.

Default –
errorMessageNexera
ReactNode | ((validation: ValidationResult) => ReactNode)

Error text, shown with an icon instead of the helper while the field is invalid (isInvalid, or a failed isRequired / validate after submit), linked with aria-describedby and announced politely. Say what is wrong and what to do ("Incorrect code. 2 attempts left.").

Default –
statusNexera
"verifying" | "success"

Verification status: a status line with an icon replaces the helper, the cells show Filled or Success, the field becomes read-only and the resend text is hidden. The status line is a polite live region (WCAG 4.1.3). Typing, Filled and Focused are not statuses: they follow from focus and the value.

Default –
statusMessageNexera
ReactNode

Text of the status line. Translate it for your locale.

Default "Verifying" for `status="verifying"`, "Verified" for `status="success"`
resendNexera
ReactNode

Resend text at the end of the footer, for example "Resend in 0:42" or "Resend code". Shown when provided, except while a status is shown or the field is disabled. A countdown is plain text and is not announced on every tick.

Default –
onResendNexera
() => void

Makes resend a button. Called on click, Enter or Space. Without it the resend text is plain text (a countdown).

Default –
onCompleteNexera
(code: string) => void

Called when the code reaches length digits (typed, pasted or autofilled). Verify in place and show status; do not submit a form or navigate away on this alone (WCAG 3.2.2, no change of context on input).

Default –
progressLabelNexera
(entered: number, total: number) => string

Text read with the field (linked with aria-describedby, visually hidden) that says how many digits are entered. Translate it.

Default (entered, total) => `${entered} of ${total} digits entered`
inputRefNexera
Ref<HTMLInputElement>

Ref to the native <input> (the root ref points to the field wrapper).

Default –
classNameNexera
string

Extra classes for the root, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style of the root.

Default –
labelNexera
FieldLabelContent

Visible label, linked to the control by React Aria (WCAG 1.3.1, 3.3.2). Short noun, for example "Work email". Wraps instead of truncating. A placeholder is never a substitute for it. Not set: the field has no visible label. Not set: the field has no visible label of its own.

Default –
aria-labelNexera
string

Accessible name when it must differ from the visible label. Prefer the visible label (WCAG 2.5.3). Accessible name. Required when there is no visible label; translate it. Accessible name. Optional when aria-labelledby is set.

Default –
aria-labelledbyNexera
string

Id(s) of element(s) that name the field; wins over the visible label. Id(s) of element(s) that name the field; wins over aria-label. Id(s) of visible element(s) that name the field.

Default –
validationBehaviorReact Aria
"native" | "aria"

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Default 'native'
enterKeyHintReact Aria
"search" | "enter" | "done" | "go" | "next" | "previous" | "send"

An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).

Default –
isDisabledReact Aria
boolean

Whether the input is disabled.

Default –
isReadOnlyReact Aria
boolean

Whether the input can be selected but not changed by the user.

Default –
isRequiredReact Aria
boolean

Whether user input is required on the input before form submission.

Default –
isInvalidReact Aria
boolean

Whether the value is invalid.

Default –
validateReact Aria
(value: string) => true | ValidationError | null

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

Default –
autoFocusReact Aria
boolean

Whether the element should receive focus on render.

Default –
valueReact Aria
string

The current value (controlled).

Default –
defaultValueReact Aria
string

The default value (uncontrolled).

Default –
onChangeReact Aria
(value: string) => void

Handler that is called when the value changes.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
autoCompleteReact Aria
string

Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).

Default one-time-code
inputModeReact Aria
"none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search"

Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).

Default numeric
autoCorrectReact Aria
string

An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocomplete).

Default –
spellCheckReact Aria
string

An enumerated attribute that defines whether the element may be checked for spelling errors. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).

Default –
nameReact Aria
string

The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).

Default –
formReact Aria
string

The <form> element to associate the input with. The value of this attribute must be the id of a <form> in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

13 direct · 3 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.3.2Meaningful SequenceLevel A · tested directly
  • 1.3.5Identify Input PurposeLevel AA · tested directly
  • 1.4.1Use of ColorLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.4.3Focus OrderLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · supporting test
  • 3.3.1Error IdentificationLevel A · tested directly
  • 3.3.2Labels or InstructionsLevel A · tested directly
  • 3.3.3Error SuggestionLevel AA · tested directly
  • 3.3.7Redundant EntryLevel A · tested directly
  • 3.3.8Accessible Authentication (Minimum)Level AA · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly
  • 4.1.3Status MessagesLevel AA · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-disabled
  • data-hovered
  • data-pressed
Usage
<OTPInput className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

Related components