Flip Text
A 3D flip text animation component that creates a mesmerizing character-by-character flip effect. Each character rotates on the X-axis with staggered timing for a smooth, wave-like animation.
Build beautiful interfaces
Install using CLI
npx shadcn@latest add "https://vengeance-ui.vercel.app/r/flip-text.json"Install Manually
1
Install dependencies
2
Add the CSS to your global stylesheet
Add the following CSS to your app/globals.css file
3
Copy the source code
Copy the code below and paste it into components/ui/flip-text.tsx
Usage
import { FlipText } from "@/components/ui/flip-text";
export default function Example() {
return (
<FlipText className="text-4xl font-bold">
Your amazing text here
</FlipText>
);
}Examples
Custom Duration
Fast Animation
Slow Animation
With Delay
Delayed Start
Different Styles
Bold & Colorful
Light & Italic
Monospace Text
Props
| Prop Name | Type | Default | Description |
|---|---|---|---|
| children | string | - | The text content to animate. Must be a string. |
| className | string | - | Additional CSS classes to apply to the wrapper element. |
| duration | number | - | Duration of the flip animation in seconds. |
| delay | number | - | Initial delay before animation starts in seconds. |
| loop | boolean | - | Whether the animation should loop infinitely or play once. |
| separator | string | - | Custom separator for splitting text. Default is space. |
| onAnimationComplete | () => void | - | Callback function triggered when animation completes one cycle. |
How It Works
The FlipText component creates a 3D flip animation using:
- Character Splitting: Text is split into individual characters
- Staggered Delays: Each character gets a calculated delay using a sine wave function for smooth progression
- 3D Transforms: Characters flip along the X-axis using CSS
rotateX() - Dual Faces: Each character has two faces (front and back) created with
::beforeand::afterpseudo-elements - CSS Variables: Animation timing is controlled via CSS custom properties (
--flip-duration,--flip-delay)
The sine wave delay calculation creates a natural wave effect across the text, making the animation more visually appealing than a linear delay progression.