This component requires the
motion-sv dependency.Installation
This component requires CSS keyframes to be added to your global styles. The installation command will handle this automatically.
Usage
Examples
Basic Example
Simple line shadow text with default settings.Custom Shadow Color
Change the color of the diagonal line shadow.Different Element Types
Render as different HTML elements.Large Display Text
Use with large typography.Colored Text with Shadow
Combine text color with shadow color.Multiple Lines
Use with multi-word content.Props
The text content to display with the line shadow effect.
The color of the diagonal line shadow. Accepts any valid CSS color value.
The HTML element type to render. Options:
span, div, p, h1, h2, h3, h4, h5, h6.Additional CSS classes to apply to the component.
CSS Animation
The component uses a CSS keyframe animation that is automatically added during installation:How It Works
The line shadow effect is created using:- Pseudo-element: An
::afterpseudo-element positioned behind the text - Linear gradient: A 45-degree striped pattern using CSS gradients
- Background clipping: The gradient is clipped to text shape using
bg-clip-text - Animated position: The background position animates to create movement
- Data attribute: The text content is duplicated via the
data-textattribute
Technical Details
The shadow is created by:- Positioning a pseudo-element slightly offset (0.04em) from the main text
- Using a diagonal linear gradient (45deg) to create parallel lines
- Animating the background position to create the moving effect
- Making the gradient transparent so it acts as a shadow/outline
Customization
Faster Animation
Speed up the line movement.Slower Animation
Slow down for a more subtle effect.Reverse Direction
Make the lines move in the opposite direction.Pause on Hover
Freeze the animation when hovering.Transparent Shadow
Use semi-transparent colors for a subtle effect.Dark Mode Compatibility
Use CSS variables for theme-aware shadows.Use Cases
- Hero headings: Add dynamic interest to landing page titles
- Brand names: Make logos and brand text more distinctive
- Section headers: Enhance content section titles
- Feature callouts: Draw attention to key features
- Artistic displays: Create visually interesting text treatments
- Loading states: Indicate activity with animated text
Performance
The animation is CSS-based and GPU-accelerated, making it very performant. The effect uses:- Transform and opacity (GPU-accelerated properties)
- Background position animation
- No JavaScript-based animation loops
The component uses
whitespace-pre to preserve spacing in the content string. This is important for maintaining the exact text layout you provide.