Input Otp
One-time passcode field split into separate slots.
Installation
bun add @xerobi/ui
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "@xerobi/ui/input-otp"This component is client-side. In Astro, hydrate it with a client directive.
Examples
Default
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@xerobi/ui/input-otp"
export function InputOTPDefault() {
return (
<InputOTP maxLength={6} aria-label="Verification code">
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
)
}API reference
InputOTP
| Prop | Type | Description |
|---|---|---|
| containerClassName | string |
InputOTPGroup
Also accepts every prop of <div> element.
No props of its own.
InputOTPSeparator
Also accepts every prop of <div> element.
No props of its own.
InputOTPSlot
Also accepts every prop of <div> element.
| Prop | Type | Description |
|---|---|---|
| index* | number |
Styling hooks: [data-slot="input-otp"], [data-slot="input-otp-group"], [data-slot="input-otp-slot"], [data-slot="input-otp-separator"].