PREMIUM SWEEP
INTERACTION_041CSS
Gradient Text Sweep
A light band travels through the letterforms like a reflection.
Text / LightView
A marker-style highlight wipes behind a keyword. No background, scaled to 0 width from the left before the trigger; scaling the highlight from 0 to 1 on the X axis with origin left once the sentence enters view.
/* Text Highlight Sweep — A marker-style highlight wipes behind a keyword. */
.text-highlight-sweep {
--dur: 520ms;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--stagger: 60ms;
will-change: transform, opacity;
}
.text-highlight-sweep > * {
opacity: 0;
transform: translateY(14px);
animation: text-highlight-sweep-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* no background, scaled to 0 width from the left -> scaling the highlight from 0 to 1 on the X axis with origin left */
@keyframes text-highlight-sweep-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.text-highlight-sweep > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Text Highlight Sweep — trigger: the sentence enters view */
export function TextHighlightSweep({ 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="text-highlight-sweep" data-state="out">
{children}
</div>
);
}A light band travels through the letterforms like a reflection.
Copy resolves from a soft blur into perfect focus as it enters view.
Each line slides up from behind an invisible mask, one after the other.
Words fade up in sequence so the sentence assembles as you read it.