How to build an accessible OtpInput in React

Wraps the slots in role="group" with a localized aria-label and labels each slot with its position so screen readers announce which digit is being entered; the first slot carries autoComplete="one-time-code" so platform SMS autofill can populate the code.

When to use a OtpInput

When not to use it

Keyboard interactions

Role group, verified at WCAG 2.2-AA.

Common mistakes

Avoid: <Input maxLength={6} placeholder="Enter code" />

Prefer: <OtpInput length={6} value={code} onValueChange={setCode} />

OtpInput gives per-digit slots with auto-advance, backspace-to-previous, full-code paste handling, and autoComplete="one-time-code" that a single Input does not

Example

<OtpInput value="" onValueChange={() => {}} />

See the full OtpInput reference →