Overview
Gradient Reveal Text maps scroll progress onto every word of a paragraph. Unread words sit dimmed in the text colour; as the paragraph travels through the viewport — or through any scrollable container you pass in — each word cross-fades into its slice of a two-colour gradient. Accents are deepened automatically on light backgrounds for contrast, the progress can be spring-smoothed, and reduced-motion users get the fully revealed paragraph.
01Installation
Method 01 · Registry
CLI verifiedUses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/gradient-reveal-text.tsx and adds its dependencies.
npx shadcn@latest add https://wancraft.my/r/gradient-reveal-text.jsonMethod 02 · Copy and paste
- 1. Install the dependencies below.
- 2. Copy the source from the Code tab into
components/ui/gradient-reveal-text.tsx. - 3. Import it and adjust props.
npm install motion- Dependencies
- motion
- Peer
- react ≥ 18, tailwindcss ≥ 4
- Added
- 1 Oct 2026
- Updated
- 13 Oct 2026
02Usage
The default configuration. Change properties above to generate a tailored example in the Usage tab.
import { GradientRevealText } from "@/components/ui/gradient-reveal-text";
export function GradientRevealTextExample() {
return (
<GradientRevealText
className="max-w-2xl text-4xl font-semibold tracking-tight"
>
Good interfaces explain themselves as you move through them. Every word arrives when you are ready for it, and nothing competes for attention.
</GradientRevealText>
);
}03Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | string | — | The paragraph text. |
| as | "p" | "h2" | "h3" | "blockquote" | "div" | "p" | Element to render. |
| container | RefObject<HTMLElement | null> | — | Scrollable ancestor to track (give it a non-static position). Defaults to the window. |
| direction | "forward" | "reverse" | "forward" | Reveal words from first to last, or last to first. |
| accent | string | "#FF7448" | Gradient start colour. |
| accentSecondary | string | "#B6F3D1" | Gradient end colour. Both accents are mixed towards ink on light backgrounds. |
| dimOpacity | number | 0.18 | Opacity of words not yet revealed (0–1). |
| softness | number | 3 | How many words are mid-transition at once. |
| smooth | boolean | true | Spring-smooth the scroll progress. |
| offset | ScrollOffset | ["start 0.85", "end 0.45"] | motion useScroll offsets defining where the reveal starts and ends. |
| ...props | HTMLAttributes | — | Native attributes are forwarded to the root element. |
04Features
- 01Scroll progress mapped per word with motion useScroll — no scroll listeners in React state
- 02Works with the window or any scrollable container ref
- 03Continuous two-colour gradient across the paragraph via color-mix
- 04Theme-aware: accents deepen on light backgrounds, stay luminous on dark
- 05Adjustable softness, direction and spring smoothing
05Accessibility
- The paragraph is exposed once as visually hidden text; the per-word layers are aria-hidden.
- Text is always present in the DOM — the effect only changes colour and opacity.
- With prefers-reduced-motion the paragraph renders fully revealed and static.
06Limitations
- Unrevealed words are intentionally low-contrast; keep dimOpacity high enough if the text must be legible before scrolling.