This component requires the
motion-sv dependency.Installation
Usage
Examples
Basic Example
Simple stagger text with default settings.As Different Elements
Render as different HTML heading elements.Large Display Text
Use with large typography for hero sections.Colored Text
Apply custom colors and styles.Multiple Lines
Create stagger effects on multiple text elements.Navigation Links
Use in navigation for interactive links.Props
The text content to display with the stagger animation.
The HTML element type to render. Options:
span, h1, h2, h3, h4, h5, h6.Additional CSS classes to apply to the component.
Animation Details
The stagger animation uses motion-sv with custom variants:How It Works
The stagger effect is created through:- Character splitting: Text is split into individual characters
- Dual layers: Each character has two versions (original and copy)
- Hover state: Mouse enter/leave triggers the animation
- Ripple effect: Characters animate based on distance from hovered character
- Vertical translation: Characters slide up 100% to reveal the copy underneath
- Staggered timing: Delay increases based on distance from active character
Key Features
- Interactive: Responds to mouse hover
- Ripple effect: Characters animate outward from hovered position
- Smooth transitions: Uses easeInOut easing for natural motion
- Copy support: Handles text copying correctly
- Accessibility: Includes screen reader text and proper ARIA attributes
Customization
Faster Animation
Speed up the stagger effect by modifying the component or wrapping with custom styles.Different Colors on Hover
Use CSS to change colors during interaction.Gradient Text
Apply gradients to the text.Uppercase Styling
The component displays text as-is, but you can force case with CSS.Letter Spacing
Adjust spacing between characters.Use Cases
- Hero headings: Create interactive hero section titles
- Navigation menus: Add playful hover effects to nav items
- Call-to-action: Make CTAs more engaging
- Portfolio headers: Great for creative portfolios
- Brand names: Make brand text memorable
- Section titles: Add interest to content sections
- Interactive logos: Animate logo text on hover
Best Practices
- Font choice: Works best with bold, sans-serif fonts
- Text length: Most effective with short text (1-3 words)
- Sizing: Larger text sizes show the effect more clearly
- Contrast: Ensure sufficient contrast with background
- Spacing: Use appropriate letter spacing for readability
Accessibility
The component includes several accessibility features:- Screen reader text in an
h1tag withsr-onlyclass - Proper
aria-labelon the main element aria-hidden="true"on decorative animated spans- Copy event handling to preserve correct text content
Performance
The animation is GPU-accelerated using CSS transforms (translateY), ensuring smooth 60fps performance. The component uses motion-sv for optimized animations.
The stagger delay is calculated based on distance from the hovered character, creating a ripple effect that feels natural and responsive.