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

OTPCell

  • Stable
  • WCAG 2.2 evidence
  • RTL

One character box of a one-time code. A presentational part of {@link OTPInput }, which renders the cells from its value and marks the active one with data-focused (and data-hovered while hovered); Figma advises against using a cell on its own. Empty and Filled follow from digit; Focused is the data-focused attribute (rule G1). Renders in React Server Components. Inside OTPInput the row of cells is hidden from assistive technology: one real input carries the value, the label and the messages, so screen readers meet a single labelled field (WCAG 1.3.1, 4.1.2).

import { OTPCell } from "@nexera-ui/react";
Loading example…
2
examples
6
props
4
live controls
1
platform
5
WCAG criteria
0
blocks use 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…
isMasked
size
isInvalid
isDisabled
Generated code
import { OTPCell } from "@nexera-ui/react";

<OTPCell />

Examples 1

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

Masked

Masked cells show a dot in the digit colour instead of the character.

Loading example…

Props 6

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

6 props shown

digitNexera
string

The character shown in the cell. Shown when provided; an empty cell shows nothing, or the caret while it is focused. The Figma sample "4" is example content.

Default –
isMaskedNexera
boolean

Show a dot instead of the character. The character is not rendered at all, so it is not exposed to assistive technology either.

Default false
sizeNexera
"md" | "lg"

Cell size: 40 px with Heading/H3, or 48 px with Heading/H2.

Default md
isInvalidNexera
boolean

Error state: danger stroke and danger digit colour. The field that owns the cell must also show the error as text (WCAG 1.4.1, 3.3.1); OTPInput does.

Default false
isDisabledNexera
boolean

Disabled state: sunken fill and disabled text.

Default false
statusNexera
"success"

Semantic status: success stroke. Say it in text as well (OTPInput shows "Verified").

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

2 direct · 3 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · supporting test
  • 1.4.11Non-text ContrastLevel AA · supporting test
  • 2.4.7Focus VisibleLevel AA · supporting test

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-filled
  • data-focused
  • data-hovered
  • data-invalid
Usage
<OTPCell className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

No block uses OTPCell yet.

Related components