Input OTP

Enters a one-time code, one character per slot.

@paneui/theme@paneui/icons@paneui/control-size@base-ui/reactclass-variance-authority

Installation

pnpm dlx shadcn@latest add @paneui/input-otp

Usage

Composition

Examples

Four Digits

Use for a PIN that should stay hidden.

Accessibility

Label the first slot with the field label and give the rest aria-labels such as "Character 2 of 6". Pasting fills every slot; autoComplete is one-time-code so phones offer the code from a message.

API Reference

Built on the OTP Field primitive. Only the props this library adds or changes are listed; everything else passes through.

InputOTP

Also accepts every prop of OTPField.Root.

length*
number
Number of slots.
size= "default"
"xs" | "sm" | "default" | "lg"
Slot size (24 / 28 / 32 / 36px). Inside a sized Field it follows the field.
onValueComplete
(value: string) => void
Called when every slot is filled.
PropTypeDefaultDescription
length*number—Number of slots.
size"xs" | "sm" | "default" | "lg""default"Slot size (24 / 28 / 32 / 36px). Inside a sized Field it follows the field.
onValueComplete(value: string) => void—Called when every slot is filled.

InputOTPSlot

Also accepts every prop of OTPField.Input.

data-filled
Present when the slot holds a character.
Data attributeDescription
data-filledPresent when the slot holds a character.

InputOTPGroup

Also accepts every prop of div.

InputOTPSeparator

Also accepts every prop of div.