Skip to content
Storybook

Verification code

One-time code input. Auto-advances, accepts paste of the full code and stays LTR in every locale.

Preview

React · live from the Storybook

HTML and CSS

The same component as plain HTML with pixels-ui.css, no framework needed.

Enter the 6-digit code

Usage

  • Use autocomplete="one-time-code" on the first cell.
  • Let people paste the whole code.

Installation

Included in the core files. No extra install.

HTML
<link rel="stylesheet" href="/css/pixels-tokens.css">
<link rel="stylesheet" href="/css/pixels-ui.css">
<script src="/js/pixels-ui.js" defer></script>

Examples

Four digits, large, error

API reference

Class / attributeTypeDescription
px-otpclassGroup of single-digit inputs.
px-otp--lgclassLarge cells (64px).
px-otp--errorclassError state.

Figma properties

Verification code6 variants · page “Input Fields”Open

One-time code input built from Verification code / Cell. Use autocomplete="one-time-code" and accept paste of the full code.

PropertyTypeValues
DigitsVariant4 6
StateVariantEmpty Filled Error
Verification code / Cell10 variants · page “Input Fields”Open

One digit of a one-time code. Digits stay LTR in every locale.

PropertyTypeValues
DigitText“0”
SizeVariantMedium Large
StateVariantActive Focused Filled Error Disabled

Design tokens

Component tokens from the Figma Component collection. Override them to restyle just this component.

TokenAliasLight value
--px-code-input-size-mdspacing-4848px
--px-code-input-size-lg64px64px
--px-code-input-radiusradius-1212px

Accessibility

  • Each cell has aria-label “Digit n”.
  • Group with role="group" and a label.