StealThis .dev

Text Highlighter

Text where words get highlighted one-by-one with a colored background sweep animation. Each word receives a sequential highlight effect from left to right.

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

Code

Text Highlighter

Words in a paragraph are highlighted one-by-one with a colored background sweep that animates from left to right, creating a reading or karaoke-style effect.

How it works

Each word is wrapped in a <span> with a ::before pseudo-element that acts as the highlight background. JavaScript staggers the animation delay on each span so they trigger sequentially.

Features

  • Sequential highlight — words light up one after another
  • Customizable color — change the highlight hue via CSS variable
  • Replay on click — click to restart the animation
  • Smooth sweep — background animates from scaleX(0) to scaleX(1)