Installation
Usage
Examples
Basic Example
Cycle through multiple words with a smooth morph effect.Feature Highlights
Showcase multiple product features.Brand Values
Rotate through brand messages.With Custom Styling
Apply custom styles to the container.Hero Section
Use in a hero section with large text.Props
Array of text strings to cycle through. The component will continuously morph between these values.
Additional CSS classes to apply to the component container.
Animation Timing
The component uses fixed timing constants for the morphing effect:- Morph time: 1.5 seconds (duration of the morph transition)
- Cooldown time: 0.5 seconds (pause between morphs)
How It Works
The morphing effect is achieved through:- Dual text layers: Two overlapping
<span>elements contain the current and next text - Blur transition: Text blurs as it morphs from one to another
- Opacity fade: Text fades out while morphing
- SVG filter: An SVG threshold filter enhances the morph effect
- Animation loop: Continuous requestAnimationFrame loop drives smooth animation
Technical Details
SVG Filter
The component uses an SVG color matrix filter to sharpen the blur transitions:Customization
Two Words Only
Morph between just two words.Many Words
Cycle through a large set of words.Longer Phrases
Morph between complete phrases.Custom Colors
Style the text with custom colors.Smaller Size
Adjust for smaller text sizes.Use Cases
- Hero sections: Create dynamic, eye-catching headlines
- Feature showcases: Rotate through product features
- Brand messaging: Cycle through brand values or USPs
- Loading states: Show dynamic loading messages
- Multi-language support: Display text in multiple languages
- Testimonials: Rotate through customer quotes
- Stats rotation: Cycle through different metrics
Best Practices
- Similar length texts: Works best when texts are similar in length
- Contrast: Ensure sufficient contrast with background
- Font selection: Bold, sans-serif fonts work best
- Center alignment: The effect is most visible with center-aligned text
- Limited count: 3-6 texts provide the best user experience
Accessibility
Considerations for accessibility:- The component cycles automatically, which may be distracting for some users
- Text is always readable, but morphs continuously
- Consider adding a pause button for users who need it
- Ensure text content is meaningful and not critical information that might be missed
The morphing effect is created using a combination of blur filters and opacity transitions, enhanced by an SVG threshold filter that creates sharp edges during the transition.
Performance
The component usesrequestAnimationFrame for smooth, 60fps animations. The animation is automatically cleaned up when the component is destroyed to prevent memory leaks.