Overview
A gradient text sweep paints a moving highlight band through headline text via background-clip: text on an oversized background gradient. The text node stays live in the DOM — selectable, copyable, AT-readable — while a narrow bright band crosses the glyph shapes without any per-letter spans or canvas hacks. Behind a @supports guard, browsers without background-clip-text fall through to a solid fallback color so nothing renders as invisible.
When to use it
Reach for gradient text sweeps on launch headlines, single-line CTAs, marquee strap lines — anywhere one prominent string is the visual hero. Skip it for paragraph copy; the sweep is beautiful at 64px and unreadable at 14px. Skip it when the rest of the page is already loud — a sweep next to a gooey blob or particle burst reads as a third competing element, not a refined accent.
How it works
Set background-image on the text to a linear gradient with explicit color stops including the bright sweep band, then set background-size larger than 100% on the x-axis (e.g. 260% 100%) so the gradient is wider than the text. Clip the background to the glyphs with background-clip: text + -webkit-background-clip: text and set color: transparent + -webkit-text-fill-color: transparent. Now animate background-position from 0% 50% to 100% 50% — the sweep moves across the oversized gradient and the visible part inside the glyphs shifts in lockstep.
Production gotchas
The @supports guard is non-negotiable — omit it and Firefox versions without the property render invisible text (color transparent + no clip = nothing). Animating background-position as a string can confuse certain browsers’ transition interpolation; if you see janky stepping, switch to a keyframe that interpolates a --bg-pos custom property via @property instead. Drop shadows behind clipped text render as the shadow of the glyphs, not the gradient — for a colored glow behind the sweep use filter: drop-shadow, not text-shadow.
Accessibility
The text node remains real DOM content so screen readers and search engines see the string normally. The sweep is purely decorative; on prefers-reduced-motion: reduce the animation pauses with the gradient pinned at a middle position so the headline still reads as gradient-clipped without the moving band. Always verify the fallback color (and the gradient at its rest position) meets WCAG AA contrast against the surface behind it.
References
Implementation depth
The live text node is the product; the moving gradient is just paint. Use background-clip: text with a supports guard, then animate background-position across an oversized gradient so the glyph outlines remain selectable.
The fallback color matters because transparent text without clipping becomes invisible. Verify contrast for the fallback and the paused reduced-motion frame, especially when the sweep sits over a busy hero background.