Back to Components
OTP Input
A self-contained OTP/verification-code input with four independently functional variants (bordered squares, underline, connected capsule, filled tiles). A Framer Motion spring drives the focus indicator between slots using real measured positions.
Preview
Installation
Install the component using the CLI.
npx shadcn@latest add https://shreyashtech.me/r/otp-input.jsonUsage
Import the component:
import OtpShowcase, { OtpInput } from "@/components/otp-input"Use it in your code:
<OtpInput length={6} variant="classic" />Props
| Property | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | Number of digit slots. |
| variant | "classic" | "underline" | "pill" | "filled" | all four | Render a single style. |
| onComplete | function | - | Called when all slots are filled. |