Big statement paragraphs feel cinematic when each word brightens as the reader reaches it. We split the text into words and give each one its own slice of the scroll.
app/components/Statement.tsxCopy "use client";
import { useRef } from "react";
import { motion, useScroll, useTransform, type MotionValue } from "motion/react";
export default function Statement({ text }: { text: string }) {
const ref = useRef<HTMLParagraphElement>(null);
const { scrollYProgress } = useScroll({ target: ref, offset: ["start 0.85", "end 0.35"] });
const words = text.split(" ");
return (
<p ref={ref} className="mx-auto max-w-4xl px-6 py-40 text-4xl font-medium leading-tight md:text-6xl">
{words.map((w, i) => (
<Word key={i} progress={scrollYProgress} range={[i / words.length, (i + 1) / words.length]}>{w}</Word>
))}
</p>
);
}
function Word({ children, progress, range }: { children: string; progress: MotionValue<number>; range: [number, number] }) {
const opacity = useTransform(progress, range, [0.15, 1]);
return <motion.span style={{ opacity }} className="mr-[0.25em] inline-block">{children}</motion.span>;
}