Accessible one-time password input with copy/paste support.
Loading...
"use client"
import {Installation
pnpmnpmyarnbun
Usage
import {
InputOTP,
InputOTPGroup,
InputOTPSlot,
} from "@/components/ui/input-otp"<InputOTP maxLength={6}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>Examples
With Separator
Use InputOTPSeparator to add a visual separator between groups.
Loading...
"use client"
import {Controlled
Control the input value with value and onChange.
Loading...
"use client"
import * as React from "react"Pattern
Use the pattern prop to restrict input to specific characters.
Loading...
"use client"
import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp"API Reference
InputOTP
The root component that manages the OTP input state.
InputOTPGroup
Groups slots together visually.
InputOTPSlot
Individual character slot.
InputOTPSeparator
Visual separator between groups.
Credits
Built on top of input-otp by @guilhermerodz.