Skip to content

Input OTP

Accessible one-time password input with joined character slots.

Install

Bash
npx @madeui/cli add input-otp

Usage

TSX
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from '@/components/ui/input-otp';

Composition

TSX
<InputOTP length={6}>
  <InputOTPGroup>
    <InputOTPSlot />
    <InputOTPSlot />
    <InputOTPSlot />
  </InputOTPGroup>
  <InputOTPSeparator />
  <InputOTPGroup>
    <InputOTPSlot />
    <InputOTPSlot />
    <InputOTPSlot />
  </InputOTPGroup>
</InputOTP>

Separator

Disabled

Controlled

Enter your code.

API reference

Built on Base UI OTP Field — every slot is a real <input>, so focus, caret, and paste behavior come from the platform. All props are forwarded to the Base UI Root (length is required; value, onValueChange, mask, validationType, autoSubmit, …); see the Base UI OTP Field API reference. Each part also accepts a style prop (StyleXStyles, merged last). InputOTPSlot maps to a Base UI Input; slot order determines the character index.

Was this page helpful?