About
A set of input boxes for entering a one-time passcode or verification code, with optional grouping separators, large size, and disabled states.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds OTP Field to your project and fits it to your theme.
Code
How OTP Field is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import { Label } from "@/components/ui/label";
import {
OTPField,
OTPFieldInput,
OTPFieldSeparator,
} from "@/components/ui/otp-field";
function slots(from: number, count: number, total: number) {
return Array.from({ length: count }, (_, i) => (
<OTPFieldInput
aria-label={`Character ${from + i + 1} of ${total}`}
key={from + i}
/>
));
}
export default function OTPFieldDemo() {
return (
<div className="flex flex-col items-start gap-5">
<div className="flex flex-col gap-2">
<Label>Verification code</Label>
<OTPField aria-label="Verification code" length={6}>
{slots(0, 3, 6)}
<OTPFieldSeparator />
{slots(3, 3, 6)}
</OTPField>
</div>
<div className="flex flex-col gap-2">
<Label>PIN (large)</Label>
<OTPField aria-label="PIN" length={4} size="lg">
{slots(0, 4, 4)}
</OTPField>
</div>
<div className="flex flex-col gap-2">
<Label>Disabled</Label>
<OTPField aria-label="Disabled code" disabled length={6}>
{slots(0, 6, 6)}
</OTPField>
</div>
</div>
);
}








