Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Input OTP for React and Tailwind

Accessible one-time password input.


Installation

bunx --bun shadcn@latest add https://kit.dev/r/input-otp.json

Anatomy

InputOTP
├── InputOtpLabel
├── InputOTPSlot
└── InputOtpControl

Usage

import {
  InputOTP,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp";
<InputOTP>
  <InputOTPSlot index={0} />
  <InputOTPSlot index={1} />
  <InputOTPSlot index={2} />
  <InputOTPSeparator />
  <InputOTPSlot index={3} />
  <InputOTPSlot index={4} />
  <InputOTPSlot index={5} />
</InputOTP>

Accessibility

KeyDescription
Backspace
Delete backward.
Delete
Delete.
ArrowLeft
Move left.
ArrowRight
Move right.
Enter
Activate the focused item.
Home
Go to the start.
End
Go to the end.

Demos

Blur On Complete

Controlled

Custom Size

Disabled

Four Digits

Invalid

Mask

Separator

With Placeholder

API Reference

InputOTP

div

PropType
AttributeType

InputOTPSlot

input

PropType
AttributeType

InputOtpControl

div

PropType

InputOTPSeparator

hr

PropType
AttributeType