# Integrate `Lumen` from Motion Garden

You are helping me add the **Lumen** 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:** Lumen
- **Category:** Text Animations
- **Summary:** Copy that lights up as you read it. Words ahead sit dim and unfocused, and stay lit once you pass them.
- **Reference:** https://motion-garden.netlify.app/components/lumen
- **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 motion clsx tailwind-merge
```

## Files to create

2 files — all of them are required. 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/lumen/lumen.tsx`

```tsx
"use client";

import { useMemo, useRef, type RefObject } from "react";
import {
  motion,
  useScroll,
  useTransform,
  useMotionTemplate,
  type MotionValue,
} from "motion/react";
import { cn } from "@/lib/utils";

export interface LumenProps {
  text?: string;
  className?: string;
  dimOpacity?: number;
  fadeSpan?: number;
  blurAmount?: number;
  startOffset?: number;
  endOffset?: number;
  highlightColor?: string;
  scrollContainerRef?: RefObject<HTMLElement | null>;
  reducedMotion?: boolean;
}

interface WordProps {
  word: string;
  progress: MotionValue<number>;
  start: number;
  end: number;
  dimOpacity: number;
  blurAmount: number;
  highlightColor: string;
  still: boolean;
}

function Word({
  word,
  progress,
  start,
  end,
  dimOpacity,
  blurAmount,
  highlightColor,
  still,
}: WordProps) {
  const opacity = useTransform(progress, [start, end], [dimOpacity, 1], {
    clamp: true,
  });
  const blurPx = useTransform(progress, [start, end], [blurAmount, 0], {
    clamp: true,
  });
  const filter = useMotionTemplate`blur(${blurPx}px)`;

  const glow = useTransform(
    progress,
    [start, (start + end) / 2, end],
    [0, 1, 0],
    { clamp: true },
  );
  const glowPx = useTransform(glow, (g) => g * 12);
  const textShadow = useMotionTemplate`0 0 ${glowPx}px ${highlightColor}`;

  if (still) return <span className="mr-[0.25em] inline-block">{word}</span>;

  return (
    <motion.span
      className="mr-[0.25em] inline-block will-change-[opacity,filter]"
      style={{ opacity, filter, textShadow }}
    >
      {word}
    </motion.span>
  );
}

export default function Lumen({
  text = "",
  className,
  dimOpacity = 0.15,
  fadeSpan = 6,
  blurAmount = 4,
  startOffset = 0.15,
  endOffset = 0.6,
  highlightColor = "#a855f7",
  scrollContainerRef,
  reducedMotion = false,
}: LumenProps) {
  const targetRef = useRef<HTMLParagraphElement>(null);
  const words = useMemo(() => text.split(/\s+/).filter(Boolean), [text]);

  const { scrollYProgress } = useScroll({
    target: targetRef,
    ...(scrollContainerRef ? { container: scrollContainerRef } : {}),
    offset: ["start end", "end start"],
  });

  const lo = Math.min(startOffset, endOffset - 0.05);
  const progress = useTransform(scrollYProgress, [lo, endOffset], [0, 1], {
    clamp: true,
  });

  const total = words.length || 1;
  const span = Math.min(Math.max(fadeSpan, 1), total);

  return (
    <p ref={targetRef} className={cn("text-balance", className)}>
      {words.map((word, i) => (
        <Word
          key={`${word}-${i}`}
          word={word}
          progress={progress}
          start={i / total}
          end={Math.min(1, (i + span) / total)}
          dimOpacity={dimOpacity}
          blurAmount={blurAmount}
          highlightColor={highlightColor}
          still={reducedMotion}
        />
      ))}
    </p>
  );
}
```

### 2. `lib/utils.ts` — peer util, required

```tsx
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
```


## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `dimOpacity` | `number` | `0.15` | Opacity of words that haven't been reached yet. Range 0–0.6. |
| `fadeSpan` | `number` | `6` | Width of the reading band — words mid-transition at once. Range 1–20 words. |
| `blurAmount` | `number` | `4` | Blur on a word that hasn't been reached. Range 0–12 px. |
| `startOffset` | `number` | `0.15` | Point in the scroll pass where the first word brightens. Range 0–0.5. |
| `endOffset` | `number` | `0.6` | Point by which the last word is fully lit. Range 0.3–1. |
| `highlightColor` | `string (hex)` | `"#a855f7"` | Amethyst bloom on the leading edge. |

## Usage

```tsx
import Lumen from "@/components/registry/lumen/lumen";

<Lumen
  dimOpacity={0.15}
  fadeSpan={6}
  blurAmount={4}
  startOffset={0.15}
  endOffset={0.6}
  highlightColor="#a855f7"
/>
```

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`.
- `lib/utils.ts` is required, not optional. It exports the `cn` helper the component imports from `@/lib/utils` — keep it at that path, or rewrite every `cn` import to wherever you already keep yours. If your project is shadcn-based you almost certainly have this file already; keep yours and drop mine.

## 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.
