A paragraph whose words come out of a blur one after another while the page scrolls. It is a server component with no JavaScript: every word runs the same CSS keyframes on the paragraph's view() timeline, and its own animation-range is shifted by its index. Screen readers get the whole text at once, and with reduced motion the text is simply visible.
Browser Support
Reveals words while scrolling.
Preview
The demo scrolls inside its own box: a view() timeline follows the nearest scroll container on its own.
Good interfaces explain themselves. We study how people work, sketch the flow, build it carefully and keep polishing after launch.
Installation
Usage
import { ScrollWordReveal } from "@/components/ui/scroll-word-reveal"
export default function Statement() {
return (
<section className="py-24">
<ScrollWordReveal
className="text-4xl font-semibold tracking-tight"
text="Good interfaces explain themselves. We study how people work and keep polishing after launch."
/>
</section>
)
}Examples
Softer reveal
Less blur and a higher starting opacity keep the text readable even before it is revealed.
Good interfaces explain themselves. We study how people work, sketch the flow, build it carefully and keep polishing after launch.
<ScrollWordReveal text={text} blur={2} initialOpacity={0.35} />Heavy blur, short range
A larger wordSpan makes neighbouring words appear together, a heavy blur makes the effect obvious.
Every word waits for its turn.
<ScrollWordReveal
text="Every word waits for its turn."
blur={14}
initialOpacity={0}
wordSpan={0.4}
className="text-4xl font-bold"
/>Inside a scrollable container
Nothing to pass: view() tracks the nearest scrolling ancestor, so the same component works in a panel, a modal or a docs preview. The offset lines are measured in that container's height.
<div className="h-96 overflow-y-auto">
<div className="h-80" />
<ScrollWordReveal text={text} offset={[1, 0.3]} />
<div className="h-96" />
</div>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | - | Paragraph text, split into words by whitespace |
| as | ElementType | "p" | Element to render |
| offset | [number, number] | [0.9, 0.25] | Two lines as a share of the scroll container height from the top: the reveal starts when the top of the text crosses the first and ends when its bottom crosses the second |
| blur | number | 6 | Blur of a hidden word, in px |
| initialOpacity | number | 0.15 | Opacity of a hidden word |
| wordSpan | number | 0.12 | Share of the range one word needs to fully appear |
| className | string | - | Classes for the paragraph |
| wordClassName | string | - | Classes for each word |