Overview
The Animated OTP component creates a visually engaging one-time password input demonstration with sequential digit animations and glowing border effects. It simulates a secure authentication flow with timed transitions and dramatic visual feedback. Key features:- Sequential digit reveal animation
- Glowing border that moves across each input box
- Synchronized fade-out animation on completion
- Automatic looping for continuous demonstration
- Customizable card title and description
- Cyan glow effects with blur animations
- Responsive design with dark mode support
- Showcase OTP authentication in demos or presentations
- Demonstrate security features on landing pages
- Create engaging authentication UI previews
- Illustrate timed authentication flows
Installation
Usage
With custom props
Props
The delay in milliseconds before the animation restarts. Minimum value is 3500ms to ensure the complete animation sequence finishes.
The title text displayed at the bottom of the card.
The description text displayed below the title, providing context about the OTP functionality.
Animation sequence
The component uses a carefully orchestrated animation sequence:- Digit reveal (0-2.4s): Each digit fades in sequentially with a 400ms interval
- Glow transition (moving): A cyan glowing border moves from box to box using layoutId
- Final pulse (2.25s): All boxes pulse with a cyan glow simultaneously
- Fade out (2.65s): All digits fade out together
- Loop restart: Animation resets based on the delay prop
Examples
- Default
- Custom messaging
- Faster loop
Customization
OTP digits
Modify the digits displayed by updating thedigits array at the top of the component file:
Glow color
Change the cyan glow effect to another color by updating the border and shadow colors:Animation timing
Adjust the interval between digit reveals in the useEffect:Box styling
Customize the OTP input box appearance:Dependencies
This component requires:motion/reactfor animations and layout transitionsreacthooks (useState, useEffect)
The component uses Motion’s
layoutId feature to create smooth transitions of the glowing border between input boxes.