Input OTP

An Input OTP takes a one-time code as a row of single-character slots, moving focus along as the code is typed or pasted. It is the control used for two-factor sign-in, email verification and anything else that arrives as a short numeric code.

Demo

Rendered live, with the same build of the library you install.

Six digits, split into two groups:

Value: Empty

Usage

InputOTP.tsx

Attributes

12 props
NameTypeDefaultDetails
maxLengthnumberRequiredThe maxLength prop.
valuestringOptionalThe value prop.
onChange(value: string) => voidOptionalThe onChange prop.
onComplete(value: string) => voidOptionalThe onComplete prop.
variant'primary' | 'secondary''primary'The variant prop.
disabledbooleanfalseThe disabled prop.
isInvalidbooleanfalseThe isInvalid prop.
patternstringOptionalThe pattern prop.
classNamestring''The className prop.
slotClassNamestring''The slotClassName prop.
separatorIndicesnumber[]EMPTY_SEPARATOR_INDICESThe separatorIndices prop.
aria-labelstring'One-time password'The aria-label prop.

Tags

Other components solving nearby problems.