OTP Verification Page for React
A glass OTP verification page for React that submits on the last digit, shakes on a wrong code and counts down to resend.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/otp-verification.jsonCheck your inbox
Enter the 6-digit code we sent to maya@example.com.
Didn't get it? Resend in 30s
OtpVerificationdefaultOtpVerificationLabels
Verify a code
The correct code is 123456.
Check your inbox
Enter the 6-digit code we sent to you@example.com.
Didn't get it? Resend in 15s
import { OtpVerification } from "@/components/sheenui/blocks/otp-verification";
// Package build (after the first npm release, or a packed tarball): import { OtpVerification } from "@sheenui/theme";
<OtpVerification
destination="you@example.com"
onVerify={async (code) => {
const res = await fetch("/api/verify", { method: "POST", body: JSON.stringify({ code }) });
return res.ok;
}}
onResend={async () => {
await fetch("/api/resend", { method: "POST" });
}}
/>Files to copy
10 folders · 13 files · 4 packages
- From
theme/src/ blocks/{otp-verification.tsx, icons.tsx}components/button/components/glass-card/components/otp-input/components/spinner/components/status-icons/hooks/{use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, light-follower.ts, tokens.ts}lib/{cn.ts, form.ts, heading.ts, state-light.tsx}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/otp-verification.jsonRegistry item: otp-verification. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Unlock variant
variant="unlock" puts a padlock inside a ring that fills with every digit. A right code opens the lock and floods the card with light; a wrong code rattles it and clears the digits. The correct code is 482913.
Check your inbox
Enter the 6-digit code we sent to the phone ending in 47.
Didn't get it? Resend in 15s
import { OtpVerification } from "@/components/sheenui/blocks/otp-verification";
// Package build (after the first npm release, or a packed tarball): import { OtpVerification } from "@sheenui/theme";
export function Example() {
return (
<OtpVerification
variant="unlock"
destination="the phone ending in 47"
onVerify={async (code) => code === "482913"}
onContinue={() => window.location.assign("/app")}
/>
);
}Four digits, with a Continue button
length changes the number of slots; onContinue adds a Continue button once the code is accepted. The correct code is 4821.
Check your inbox
Enter the 4-digit code we sent to +1 ••• ••• 0142.
Didn't get it? Resend in 30s
import { OtpVerification } from "@/components/sheenui/blocks/otp-verification";
// Package build (after the first npm release, or a packed tarball): import { OtpVerification } from "@sheenui/theme";
const router = { push: (to: string) => window.location.assign(to) };
export function Example() {
return (
<OtpVerification
length={4}
destination="+1 ••• ••• 0142"
onVerify={async (code) => code === "4821"}
onContinue={() => router.push("/welcome")}
/>
);
}Props
OtpVerificationLabels keys and English defaults (15)
Keyboard
Accessibility
- The digit field is named by codeLabel; wrong-code, incomplete, resent and success messages share one polite live region.
- The resend countdown is text, not color only.
- After success focus moves to Continue (or the heading).
All exports on this page
OtpVerification— A one-time-code card: digit slots, a verify button, a resend countdown and a success state.defaultOtpVerificationLabels— The English OtpVerificationLabels used when labels is omitted; a partial labels prop is merged over it.
When to use the OTP verification page
- Use OtpVerification as an OTP verification UI for the email or SMS confirmation step after sign-up, where the visitor types a six-digit code and, once it is accepted, sees a Continue button if you pass onContinue. Use it as the 2FA code screen after a password step.
- Use it for a two-factor sign-in step in an admin panel, setting length to 4 or 8 to match your provider and resendAfter to the cooldown your backend enforces.
- Use it to confirm a sensitive action such as changing a payout account, with destination naming the phone number or address so the person knows where to look.
- Skip it when you only need the bare digit field inside your own layout; the OtpInput component gives you the slots without the card, verify button and resend countdown.
- Pair it with GlassLogin or AuthSplit for the step that comes before it, and with Toast if your flow needs extra confirmation after Continue.
Frequently asked questions
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .