OtpInput

Segmented one-time code input

Category: inputs · WCAG 2.2-AA · form, otp, code, input, verification

States

Props

PropTypeDefaultDescription
lengthnumber6Number of input cells.
valuestringThe controlled value.
onValueChange(v: string) => voidCalled with the new value when it changes.
disabledbooleanfalseWhen true, disables the control and removes it from the tab order.
type'numeric' | 'alphanumeric'numericAccepted characters ('numeric' | 'alphanumeric').

Design tokens

When to use

When not to use

How to build an accessible OtpInput in React →

Examples

Basic

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

4-digit

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

Related components

← Back to docs