# Integrate `WordReveal` from Motion Garden

You are helping me add the **WordReveal** component to an existing project.
Everything you need is below — full source, dependencies, props and the
behavioural contract. Read it all before writing anything.

- **Component:** WordReveal
- **Category:** Text Animations
- **Summary:** A scroll-scrubbed word reveal — each word brightens and rises as it enters the viewport, tied directly to scroll position.
- **Reference:** https://motion-garden.netlify.app/components/word-reveal
- **Full catalog (for you, the agent):** https://motion-garden.netlify.app/llms.txt

## Stack this source assumes

- React 19 with the Next.js App Router (never the `pages/` directory)
- TypeScript, strict
- Tailwind CSS v4, CSS-first config (utilities are inline; no `tailwind.config` needed)

If my project differs, adapt the integration — but do not rewrite the animation math to suit a different stack. Ask me first.

## Dependencies

```bash
bun add gsap
```

## Files to create

One file. Paths are as shipped; the component may live anywhere in my project, but keep every peer file at the exact path shown so the import aliases resolve.

### 1. `components/registry/word-reveal/word-reveal.tsx`

```tsx
"use client";

import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { Fragment, useEffect, useRef, type RefObject } from "react";

if (typeof window !== "undefined") {
	gsap.registerPlugin(ScrollTrigger);
}

interface WordRevealProps {
	children: string;
	className?: string;
	stagger?: number;
	yOffset?: number;
	fromOpacity?: number;
	scrub?: number;
	ease?: string;
	start?: string;
	end?: string;
	scrollerRef?: RefObject<HTMLElement | null>;
	reducedMotion?: boolean;
}

export default function WordReveal({
	children,
	className,
	stagger = 0.05,
	yOffset = 30,
	fromOpacity = 0.1,
	scrub = 1,
	ease = "power2.out",
	start = "top 85%",
	end = "center center",
	scrollerRef,
	reducedMotion = false,
}: WordRevealProps) {
	const rootRef = useRef<HTMLParagraphElement>(null);
	const words = children.split(" ").filter(Boolean);

	useEffect(() => {
		const root = rootRef.current;
		if (!root || reducedMotion) return;

		const ctx = gsap.context(() => {
			gsap.fromTo(
				root.querySelectorAll(".word"),
				{ opacity: fromOpacity, y: yOffset },
				{
					opacity: 1,
					y: 0,
					stagger,
					ease,
					scrollTrigger: {
						trigger: root,
						scroller: scrollerRef?.current ?? undefined,
						start,
						end,
						scrub,
					},
				},
			);
		}, root);

		return () => ctx.revert();
	}, [
		children,
		stagger,
		yOffset,
		fromOpacity,
		scrub,
		ease,
		start,
		end,
		scrollerRef,
		reducedMotion,
	]);

	return (
		<p ref={rootRef} className={className}>
			{words.map((word, index) => (
				<Fragment key={`${word}-${index}`}>
					<span className="word inline-block">{word}</span>
					{index < words.length - 1 && " "}
				</Fragment>
			))}
		</p>
	);
}
```


## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `stagger` | `number` | `0.05` | Offset between successive words along the scrub. Range 0–0.2 s. |
| `yOffset` | `number` | `30` | Rise distance per word. Range 0–80 px. |
| `fromOpacity` | `number` | `0.1` | Resting opacity of unrevealed words. Range 0–0.6. |
| `scrub` | `number` | `1` | Smoothing lag between scroll and reveal. Range 0.1–3 s. |
| `ease` | `"power1.out" | "power2.out" | "power3.out" | "none"` | `"power2.out"` | Reveal easing along the scrub. |

## Usage

```tsx
import WordReveal from "@/components/registry/word-reveal/word-reveal";

<WordReveal
  stagger={0.05}
  yOffset={30}
  fromOpacity={0.1}
  scrub={1}
  ease="power2.out"
/>
```

The import path matches the file path above; change it if you move the component. Every value shown is the documented default — pass only what you actually want to change. The snippet lists the tunable props only: if the component's props type in the source requires others (content, handlers, data), pass those too.

## Integration rules

- Keep the `"use client"` directive. This is a client component and will not render as a Server Component.
- It fills its parent. Give the wrapper an explicit height (or a definite grid area) — against a height-auto parent it collapses to nothing.
- It takes a `reducedMotion` prop and quiesces when true. Wire it to a `prefers-reduced-motion` listener rather than hardcoding `false`.

## Your task

1. Tell me where in my project this should live and why.
2. Create the files above verbatim.
3. Wire the component into the place I point you at, with sensible props for that context.
4. Flag anything in my setup that conflicts with the stack assumptions above.

Do not restyle the component or alter the animation math unless I ask.
