Composables
ComposableOriginal

Input OTP

One-time password input with individual character fields

The input OTP is a fixed-length code entry built from individual character slots backed by one hidden input. Use it for one-time passwords, verification codes, and PINs where each character gets its own box. It is built on the input-otp library; for a Base UI version with field labeling and validation, use OTPField instead.

Preview

Value:

Installation

Usage

Composition

Use multiple InputOTPGroup blocks with an InputOTPSeparator between them to split the code into visual chunks.

Examples

With Separator

Place an InputOTPSeparator between two InputOTPGroup blocks to split the code.

Value:

Custom Pattern

Use pattern to restrict which characters each slot accepts.

Enter numbers only. Value:

Custom Styling

Pass className to InputOTPSlot to restyle the slots.

Value:

Disabled

Set disabled on InputOTP to block interaction.

Elevated Variant

Use variant="elevated" on each InputOTPSlot for translucent slots that adapt to a Card, Dialog, or popover surface. See the Surfaces docs.

On a Card surface
Use variant="elevated" on InputOTPSlot when the field sits inside a Card, Dialog, or popover.
ValueDescription
defaultOpaque bg-input slots for standard backgrounds.
elevatedTranslucent bg-input-elevated slots for layered surfaces.

Accessibility

The slots render the visible boxes, but text entry happens in a single hidden input that spans the group, so the code stays selectable, pasteable, and reachable by autofill. Set maxLength to the code length, and pass aria-invalid="true" on InputOTP to flag a rejected code.

API Reference

Props

InputOTPSlot

Prop