Skip to content
WANCRAFT

C.11Typography & Text

Gradient Reveal Text

A paragraph whose words take on an accent gradient as you scroll it into place.

UpdatedReactMotionTailwindintermediate

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 verified

Uses 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.json

Method 02 · Copy and paste

  1. 1. Install the dependencies below.
  2. 2. Copy the source from the Code tab into components/ui/gradient-reveal-text.tsx.
  3. 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.

example.tsx
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

PropTypeDefaultDescription
childrenstring—The paragraph text.
as"p" | "h2" | "h3" | "blockquote" | "div""p"Element to render.
containerRefObject<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.
accentstring"#FF7448"Gradient start colour.
accentSecondarystring"#B6F3D1"Gradient end colour. Both accents are mixed towards ink on light backgrounds.
dimOpacitynumber0.18Opacity of words not yet revealed (0–1).
softnessnumber3How many words are mid-transition at once.
smoothbooleantrueSpring-smooth the scroll progress.
offsetScrollOffset["start 0.85", "end 0.45"]motion useScroll offsets defining where the reveal starts and ends.
...propsHTMLAttributes—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
motion · scroll-linkedinput · scroll

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.