Skip to main content

InputOTP

Implemented

Multi-digit OTP input. Auto-advance between digits, paste support.

Categoryatoms
Sourcepatterns/atoms/inputotp.html
AI HintOne-time-code entry — N segmented inputs with paste distribution, auto-advance and onComplete; every segment is pinned to the 44px tap floor (DS-CORR-08-FIX7) and progress is announced via a polite live region.

Segmented one-time-password input. Supports numeric or alphanumeric codes, three sizes, and an onComplete hook for auto-submit. FR-CA: Code à usage unique segmenté.

InputOTP

Interactive atom (Family 1 — Tier 1)

Use for 2FA verification, email confirmation codes, and passwordless login flows.

Numeric — 6 segments

Alphanumeric — 8 segments

Small

This component supports light and dark mode.

Interactive demo

Valeur courante : (vide)

Usage

import { InputOTP } from '@epasslive/design-system'

<InputOTP length={6} value={code} onChange={setCode} onComplete={submitVerification} label="Code de vérification" />

Accessibility

  • Each segment is announced as "1 of 6" etc.
  • A role="status" live region announces "3 of 6 digits entered" as the code is typed, and "Code complete" when all segments are filled.
  • Auto-paste from SMS / email is supported on WebKit + Chromium.

Props

Prop
Type
Default
Description
length
number
6

Number of segments (typically 4 or 6).

value
string
—

Controlled value (digits concatenated).

onChange*
(value: string) => void
—

Per-segment change handler.

onComplete
(value: string) => void
—

Fires once when all segments are filled.

disabled
boolean
false

Disables all segments.

autoFocus
boolean
false

Focuses the first segment on mount.

type
'numeric' | 'alphanumeric'
numeric

Numeric for codes; alphanumeric for recovery codes.

size
'sm' | 'md' | 'lg'
md

Segment size.

label
string
—

Visible + announced label.

error
string
—

Validation message.

Props

Preview

InputOTP

Prop
Type
Required
Default
Description
length
number
Optional
6

Number of digits

value
string
Optional
—

Current OTP value

onChange
(value: string) => void
Required
—

Value change handler

disabled
boolean
Optional
false

Disabled state

error
string
Optional
—

Validation error

onComplete
(value: string) => void
Optional
—

Synced from source — no interface JSDoc yet; document on `InputOTP.tsx`.

autoFocus
boolean
Optional
false

Focuses the element on mount.

type
'numeric' | 'alphanumeric'
Optional
'numeric'

Underlying element/input type.

size
'sm' | 'md' | 'lg'
Optional
'md'

Visual size preset.

label
string
Optional
—

Visible label for the control.

Quick use:<InputOTP />

Accessibility

ARIA rolegroup

Type

1 rule

NASA Rule 5

length prop must equal number of input cells

ARIA

2 rules

WCAG 1.3.1

Each input must have aria-label or be in labelled group

WCAG 4.1.3

Provide aria-live='polite' for value announcements

Keyboard

1 rule

WCAG 2.1.1

Arrow keys, Backspace, and paste must be supported

Usage

Import

tsxSnippet
import { InputOTP } from "@epasslive/design-system"

Example 1

tsxSnippet
<Input label="Email" type="email" />

Example 2

tsxSnippet
<Input label="Password" type="password" required />

Anti-patterns

— Do not compose atoms directly — use molecules instead

— Avoid inline styles on atoms

Design System v4.1.0 | ePassLive