Input OTP
Accessible one-time password component with copy paste functionality.
Installation
›pnpm dlx shadcn@latest add @evolphin/input-otp
Usage
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/components/ui/input-otp";<InputOTP maxLength={6}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
</InputOTPGroup>
<InputOTPSeparator />
<InputOTPGroup>
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>Type Definitions
import { } from "input-otp";
type = .<typeof >;Examples
Default
Pattern (Alphanumeric)
Separator
API Reference
InputOTP
This component is a wrapper around input-otp. See the input-otp documentation for all available props.
| Prop | Type | Default | Description |
|---|---|---|---|
maxLength | number | - | The number of characters in the OTP. |
pattern | string | - | The regex pattern for valid characters. |
className | string | - | Additional CSS classes |
InputOTPGroup
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
InputOTPSlot
| Prop | Type | Default | Description |
|---|---|---|---|
index | number | - | The index of the slot in the OTP. |
className | string | - | Additional CSS classes |
InputOTPSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |