Back to library
INTERACTION_041

Gradient Text Sweep.

A light band travels through the letterforms like a reflection. Flat foreground color with the gradient parked off to the left before the trigger; moving the background position across the text once the element is in view, looping every 4 seconds.

CATEGORY
Text
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
PREMIUM SWEEP
CSS / CSS
/* Gradient Text Sweep — A light band travels through the letterforms like a reflection. */
.gradient-text-sweep {
  --dur: 2.4s;
  --ease: linear;
  --stagger: 60ms;
  will-change: transform, opacity;
}

.gradient-text-sweep > * {
  opacity: 0;
  transform: translateY(14px);
  animation: gradient-text-sweep-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* flat foreground color with the gradient parked off to the left -> moving the background position across the text */
@keyframes gradient-text-sweep-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gradient-text-sweep > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Gradient Text Sweep — trigger: the element is in view, looping every 4 seconds */
export function GradientTextSweep({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="gradient-text-sweep" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

HIGHLIGHTED
INTERACTION_045CSS

Text Highlight Sweep

A marker-style highlight wipes behind a keyword.

Text / LightView
BLUR TO FOCUS
INTERACTION_031CSS

Blur To Focus Reveal

Copy resolves from a soft blur into perfect focus as it enters view.

Text / LightView
MAKE IT
FEEL PREMIUM.
INTERACTION_032CSS

Masked Line Reveal

Each line slides up from behind an invisible mask, one after the other.

Text / LightView
MAKEITPREMIUM
INTERACTION_033CSS

Word By Word Reveal

Words fade up in sequence so the sentence assembles as you read it.

Text / LightView