Text Effects
Animated text with different effects
Hello, World!
This is gradient
Floating\nParagraph
Glitching Out
Wave Motion
Text Effects
A collection of stunning animated text effects that bring your content to life. From typewriter effects to gradient animations, these components provide engaging ways to display text with smooth animations and modern design patterns.
Features
- Multiple Effects: Typewriter, gradient, floating, glitch, and wave
- Smooth Animations: Fluid transitions with Motion
- Customizable: Easy to modify colors, timing, and effects
- Accessible: Proper ARIA labels and screen reader support
- Responsive: Works perfectly on all screen sizes
- Performance Optimized: Efficient animations with hardware acceleration
Installation
npm install motion/react
Basic Usage
import { AnimatedText } from "@/components/text";function MyComponent() {return <AnimatedText text="Hello, World!" variant="typewriter" />;}
Props
Prop | Type | Default | Description |
---|---|---|---|
text | string | - | Text content to animate |
variant | 'typewriter' | 'gradient' | 'floating' | 'glitch' | 'wave' | 'typewriter' | Animation variant |
speed | 'slow' | 'normal' | 'fast' | 'normal' | Animation speed |
className | string | - | Additional CSS classes |
Examples
Typewriter Effect
<AnimatedTexttext="Welcome to our amazing website!"variant="typewriter"speed={50}/>
Gradient Text
<AnimatedTexttext="Beautiful gradient text"variant="gradient"className="text-4xl font-bold"/>
Floating Effect
<AnimatedText text="Text that reveals itself" variant="floating" speed={200} />
Glitch Effect
<AnimatedTexttext="Bouncy text animation"variant="glitch"className="text-2xl"/>
Customization
Custom Colors
<AnimatedTexttext="Custom colored text"effect="gradient"className="bg-gradient-to-r from-purple-500 to-pink-500 bg-clip-text text-3xl font-bold text-transparent"/>
Different Speeds
<div className="space-y-4"><AnimatedText text="Fast animation" variant="typewriter" speed={30} /><AnimatedText text="Slow animation" variant="typewriter" speed={200} /></div>
With Callbacks
<AnimatedText text="Animation with callback" variant="typewriter" />
Advanced Usage
Multiple Effects
function MultipleEffects() {return (<div className="space-y-8"><AnimatedTexttext="Typewriter Effect"variant="typewriter"className="font-mono text-2xl"/><AnimatedTexttext="Gradient Effect"variant="gradient"className="text-3xl font-bold"/><AnimatedTexttext="Floating Effect"variant="floating"className="text-xl"/><AnimatedTexttext="Glitch Effect"variant="glitch"className="text-2xl"/></div>);}
Interactive Text
function InteractiveText() {const [text, setText] = useState("Click me to change");return (<AnimatedTexttext={text}variant="wave"className="cursor-pointer text-2xl transition-transform hover:scale-110"/>);}
Best Practices
- Appropriate Use: Use text effects sparingly for maximum impact
- Performance: Keep animations lightweight for better performance
- Accessibility: Ensure text is readable when animations are disabled
- Consistency: Use consistent animation styles throughout your application
- Mobile Optimization: Test on mobile devices for optimal experience
Accessibility
- ARIA Labels: Proper labels for screen readers
- Reduced Motion: Respects
prefers-reduced-motion
media query - Focus Management: Proper focus indicators
- Screen Reader Support: Ensure text is accessible to screen readers
Performance Tips
- CSS Transforms: Use CSS transforms for better performance
- Hardware Acceleration: Leverage GPU acceleration with
transform3d
- Optimized Animations: Use
will-change
CSS property strategically - Lazy Loading: Load heavy animations only when needed
Troubleshooting
Text not animating?
Check if Motion is properly installed and the component is wrapped in a motion provider.
Performance issues?
Consider using CSS-only animations or reducing animation complexity.
Styling conflicts?
Check for conflicting CSS classes or Tailwind CSS purging issues.
Accessibility problems?
Test with screen readers and ensure proper ARIA labels are provided.