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.json

Usage

Import the component:

import OtpShowcase, { OtpInput } from "@/components/otp-input"

Use it in your code:

<OtpInput length={6} variant="classic" />

Props

PropertyTypeDefaultDescription
lengthnumber6Number of digit slots.
variant"classic" | "underline" | "pill" | "filled"all fourRender a single style.
onCompletefunction-Called when all slots are filled.