Componentpickers1.02 KB gzipZero dependencies
Otp Verify
6-digit OTP verification with auto-advance, paste support and resend countdown.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add otp-verifyOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { OtpVerify } from "@/components/ui/otp-verify"; <OtpVerify />Source code
otp-verify.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxotp-verify.tsx94 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface OtpVerifyProps extends React.HTMLAttributes<HTMLDivElement> { length?: number; onVerify?: (code: string) => void; /** Cooldown seconds before resending */ resendSeconds?: number;} /** 6-digit OTP verification: auto-advance, paste support, resend countdown. */export function OtpVerify({ length = 6, onVerify, resendSeconds = 30, className, ...props }: OtpVerifyProps) { const [digits, setDigits] = React.useState<string[]>(Array(length).fill("")); const [seconds, setSeconds] = React.useState(resendSeconds); const refs = React.useRef<(HTMLInputElement | null)[]>([]); Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { OtpVerify } from "@/components/ui/otp-verify"; <OtpVerify />| Prop | Type | Description |
|---|---|---|
| length | number | Configures length. (Default: 6) |
| onVerify | (code: string) => void | Callback invoked on verify. |
| resendSeconds | number | Cooldown seconds before resending |