StealThis .dev

Sparkles Text

Text with floating sparkle particles that animate around it, creating a magical glittering effect using positioned elements.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Sparkles Text

Text surrounded by animated sparkle particles that float, scale, and fade around the text. Creates a magical, celebratory effect perfect for highlighting special content.

How it works

  1. The text container has position: relative to anchor sparkle elements
  2. JavaScript creates small sparkle elements (star shapes via CSS) at random positions around the text
  3. Each sparkle animates with @keyframes — scaling up, rotating, and fading out
  4. New sparkles are spawned continuously on a timer, replacing ones that have finished their animation
  5. Sparkle colors cycle through gold, white, and cyan for variety

Customization

  • --sparkle-count controls how many sparkles are active at once (default: 10)
  • --sparkle-speed controls individual sparkle animation duration
  • --sparkle-color sets the primary sparkle color
  • Sparkle size and spread radius are randomized for organic feel

When to use it

  • “New” or “Featured” labels
  • Celebration messages and success states
  • Magical or premium product headings
  • Any text that needs to feel special and eye-catching