# Integrate `HoverList` from Motion Garden

You are helping me add the **HoverList** 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:** HoverList
- **Category:** Micro-interactions
- **Summary:** A display-type list where a shared accent block springs between rows on hover while the text indents and inverts.
- **Reference:** https://motion-garden.netlify.app/components/hover-list
- **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/hover-list/hover-list.tsx`

```tsx
"use client";

import { useId, useState } from "react";
import { motion } from "motion/react";
import { cn } from "@/lib/utils";

export interface HoverListItem {
	label: string;
	meta?: string;
}

export interface HoverListProps {
	items: HoverListItem[];
	highlightColor?: string;
	invertedColor?: string;
	stiffness?: number;
	damping?: number;
	indent?: number;
	textSize?: "sm" | "md" | "lg";
	showIcon?: boolean;
	rounded?: number;
	reducedMotion?: boolean;
	className?: string;
}

const TEXT_SIZES = {
	sm: "text-xl md:text-3xl",
	md: "text-3xl md:text-5xl",
	lg: "text-4xl md:text-7xl",
} as const;

function CrossHair({ size }: { size: number }) {
	return (
		<svg width={size} height={size} viewBox="0 0 14 14" fill="none">
			<circle cx="7" cy="7" r="2" fill="currentColor" />
			<line x1="7" y1="0" x2="7" y2="4" stroke="currentColor" strokeWidth="1.5" />
			<line x1="7" y1="10" x2="7" y2="14" stroke="currentColor" strokeWidth="1.5" />
			<line x1="0" y1="7" x2="4" y2="7" stroke="currentColor" strokeWidth="1.5" />
			<line x1="10" y1="7" x2="14" y2="7" stroke="currentColor" strokeWidth="1.5" />
		</svg>
	);
}

export default function HoverList({
	items,
	highlightColor = "#a855f7",
	invertedColor = "#000000",
	stiffness = 300,
	damping = 30,
	indent = 32,
	textSize = "md",
	showIcon = true,
	rounded = 0,
	reducedMotion = false,
	className,
}: HoverListProps) {
	const uid = useId();
	const [hovered, setHovered] = useState(-1);

	const rowTransition = reducedMotion
		? "none"
		: "transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1), color 0.3s";

	return (
		<div className={className}>
			{items.map((item, i) => {
				const isActive = hovered === i;
				return (
					<div
						key={item.label}
						onMouseEnter={() => setHovered(i)}
						onMouseLeave={() => setHovered(-1)}
						className="relative flex items-center justify-between gap-4 pr-2 md:pr-6"
					>
						{isActive && (
							<motion.div
								layoutId={`${uid}-highlight`}
								transition={
									reducedMotion
										? { duration: 0 }
										: { type: "spring", stiffness, damping }
								}
								className="absolute inset-0 z-0"
								style={{
									backgroundColor: highlightColor,
									borderRadius: rounded,
								}}
							/>
						)}
						<div
							className="relative flex items-baseline gap-3 overflow-y-clip py-2"
							style={{
								transform: `translateX(${isActive ? indent : 0}px)`,
								transition: rowTransition,
							}}
						>
							<span
								className={cn("tracking-tight", TEXT_SIZES[textSize])}
								style={{
									color: isActive ? invertedColor : undefined,
									transition: reducedMotion ? "none" : "color 0.3s",
								}}
							>
								{item.label}
							</span>
							{item.meta && (
								<span
									className="text-xs font-medium uppercase tracking-widest opacity-60"
									style={{
										color: isActive ? invertedColor : undefined,
										transition: reducedMotion ? "none" : "color 0.3s",
									}}
								>
									{item.meta}
								</span>
							)}
						</div>
						{showIcon && (
							<span
								className="relative"
								style={{
									color: invertedColor,
									opacity: isActive ? 1 : 0,
									transform: `rotate(${isActive ? 0 : 45}deg)`,
									transition: reducedMotion
										? "none"
										: "opacity 0.4s, transform 0.5s 0.1s",
								}}
							>
								<CrossHair size={28} />
							</span>
						)}
					</div>
				);
			})}
		</div>
	);
}
```

### 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 |
| --- | --- | --- | --- |
| `highlightColor` | `string (hex)` | `"#a855f7"` | Color of the sliding highlight block. |
| `invertedColor` | `string (hex)` | `"#000000"` | Text and icon color while a row is highlighted. |
| `stiffness` | `number` | `300` | Spring stiffness of the sliding highlight. Range 100–600. |
| `damping` | `number` | `30` | Spring damping — lower rings longer. Range 10–60. |
| `indent` | `number` | `32` | How far the row content slides right on hover. Range 0–80 px. |
| `textSize` | `"sm" | "md" | "lg"` | `"md"` | Display type scale of the rows. |
| `showIcon` | `boolean` | `true` | Rotate a crosshair icon in on hover. |
| `rounded` | `number` | `0` | Corner radius of the highlight block. Range 0–24 px. |

## Usage

```tsx
import HoverList from "@/components/registry/hover-list/hover-list";

<HoverList
  highlightColor="#a855f7"
  invertedColor="#000000"
  stiffness={300}
  damping={30}
  indent={32}
  textSize="md"
  showIcon={true}
  rounded={0}
/>
```

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.
