Animated OTP
forgeui/animated-otpFreeComponent
Looping animated OTP input with glowing digit transitions to simulate secure, timed authentication flow.
Live preview
live · rendered by the registry
Rendered by ForgeUI on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://forgeui.in/r/animated-otp.jsonSource
1"use client";2import { cn } from "@/lib/utils";3import { motion } from "motion/react";4import React, { useEffect, useState } from "react";56const digits = ["4", "8", "3", "1", "9", "7"];78type AnimatedOTPProps = {9 delay?: number;10 cardTitle?: string;11 cardDescription?: string;12};1314const AnimatedOTP = ({15 delay = 3500,16 cardTitle = "Secure Access",17 cardDescription = "Protect accounts with a one-time password, auto-applied during every user login for enhanced security.",18}: AnimatedOTPProps) => {19 const [animationKey, setAnimationKey] = useState(0);20 const delayTime = Math.max(delay, 3500);21 useEffect(() => {22 const interval = setInterval(() => {23 setAnimationKey((prev) => prev + 1);24 }, delayTime);2526 return () => clearInterval(interval);27 }, [delayTime]);2829 return (30 <OTPinput31 key={animationKey}32 cardTitle={cardTitle}33 cardDescription={cardDescription}34 />35 );36};3738export default AnimatedOTP;3940const OTPinput = ({ cardTitle, cardDescription }: AnimatedOTPProps) => {41 const [activeIndex, setActiveIndex] = useState(0);42 const [fadeOut, setFadeOut] = useState(false);4344 useEffect(() => {45 if (activeIndex > digits.length - 1) return;4647 const interval = setInterval(() => {48 setActiveIndex((prev) => prev + 1);49 }, 400);5051 if (activeIndex === digits.length - 1) {52 setTimeout(() => {53 setFadeOut(true);54 }, 450);55 }5657 return () => clearInterval(interval);58 }, [activeIndex]);5960 return (61 <div62 className={cn(63 "relative",64 "flex items-center justify-center",65 "h-56 w-full max-w-87.5 rounded-md",66 "bg-neutral-50 ring-1 ring-black/10 dark:bg-neutral-900 dark:ring-neutral-800",67 "shadow-sm shadow-black/10",68 )}69 >70 <div className="absolute top-[25%] left-1/2 -translate-x-1/2">71 <div className="flex w-full items-center justify-center gap-3">72 {digits.map((digit, idx) => (73 <div74 key={idx}75 className={cn(76 "text-primary relative flex h-10 w-8 items-center justify-center rounded-md border border-neutral-200 bg-linear-to-br from-neutral-50 to-white dark:border-none dark:from-neutral-800 dark:to-neutral-800",77 "shadow-[0_1px_2px_rgb(0,0,0,0.1)]",78 )}79 >80 <motion.div81 className="absolute inset-0 rounded-md border border-cyan-400"82 initial={{83 opacity: 0,84// … truncated
Files it writes
More from ForgeUI
All 28 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Formanimated-form | ForgeUI | Components | Free | no deps | |
| Animated Tabsanimated-tabs | ForgeUI | Components | Free | no deps | |
| Auralisauralis | ForgeUI | Components | Free | no deps | |
| Bot Detectionbot-detection | ForgeUI | Components | Free | no deps | |
| Chromatic Fluidchromatic-fluid | ForgeUI | Components | Free | no deps | |
| Cloudscapecloudscape | ForgeUI | Components | Free | no deps | |
| Cosmicriftcosmicrift | ForgeUI | Components | Free | no deps | |
| Expandable Cardexpandable-card | ForgeUI | Components | Free | no deps |
