Advertisement

DotLottie Interactive Sparkle Header

| by Vladimir | 2 min read | code by Carmen Ansio
A11y Ready Intermediate

Tech & Dependencies

HTML SCSS JavaScript
@lottiefiles/dotlottie-web

Features

  • DotLottie Integration
  • Letter-by-Letter Stagger
  • Hover Interaction
  • Reduced Motion Support

Browser Support

Chrome 80+ Edge 80+ Firefox 75+ Safari 13+

Core

This is a DotLottie Interactive Sparkle Header. It blends high-performance character-level typography effects with the modern DotLottie animation format. Its function is to create a delightful, “juicy” hero interaction: when a user hovers over the title, the letters individually react with a staggered lift-and-tilt motion, while a complex Lottie sparkle animation plays in the background.

Specs

  • Weight: ~25 KB (DotLottie runtime + small Lottie asset).
  • Performance: Excellent. DotLottie is significantly more lightweight than standard Lottie JSON files. The character interactions are handled entirely by GPU-accelerated CSS transform properties.
  • Theming / Customization: Typography and sparkle colors are managed via CSS custom properties (--accent, --fg).
  • Responsiveness: Fluid. Uses clamp() for the font-size, ensuring the text scales gracefully from small mobile screens to large desktop monitors.
  • Graceful Degradation: The text hover effect remains fully functional via CSS even if the Lottie player fails to load or JavaScript is disabled.

Anatomy

The component bridges accessible HTML with a layered visual state.

  • HTML (The Skeleton): The title is split into individual <span> tags (.ch), allowing CSS to target each character independently. A specific .spark container provides the mount point for the Lottie canvas.
  • CSS (The Skin): Uses a complex hover cascade. By using :nth-child selectors on the .ch class, the developer applies specific transition-delay and transform values to each letter, creating a “wave” effect when the mouse enters the container.
  • JS (The Nervous System): Initializes the DotLottie player, creates a hidden <canvas> inside the sparkle container, and toggles play/pause states based on mouseenter and mouseleave events.

Logic

The logic centers on “CSS Variable-Driven Cascade” for the letter movement.

.title:hover .ch:nth-child(5) {
  transform: translateY(-7px) rotate(-1deg) scale(1.15);
  transition-delay: 0.25s;
}

Instead of using JavaScript to calculate individual letter delays, the developer defines a fixed transition-delay and transform logic for every letter position. This ensures that the “wave” is perfectly consistent every time. When .title is hovered, the CSS engine triggers the entire sequence, and the increasing transition-delay values (0.05s, 0.1s, 0.15s…) create the feeling that the letters are reacting to a physical force pulling them upward.

Feel

Playful and energetic. The combined effect of the subtle letter-by-letter lift and the “pop” of the Lottie sparkle provides immediate, high-quality feedback. It makes the text feel reactive and alive, bridging the gap between static web content and a high-end, touch-sensitive interactive application.

Advertisement