Input OTP

Slot-based OTP input fields with consistent spacing and active state styling.

OTP input

Value: ------

Installation

pnpm dlx shadcn@latest add @omni/input-otp

Usage

import { useState } from "react"
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
} from "@/components/ui/input-otp"

const [value, setValue] = useState("")

return (
  <InputOTP value={value} onChange={setValue} maxLength={6}>
    <InputOTPGroup>
      <InputOTPSlot index={0} />
      <InputOTPSlot index={1} />
      <InputOTPSlot index={2} />
      <InputOTPSlot index={3} />
      <InputOTPSlot index={4} />
      <InputOTPSlot index={5} />
    </InputOTPGroup>
  </InputOTP>
)