# Scroll Image Trail

> Drops a trail of image clones behind the cursor as it moves across the wrapped area.

Source: https://nyxui.com/components/scroll-image-trail

---
<ComponentPreview name="scroll-image-trail-demo" />

Scroll Image Trail is an interactive React wrapper that drops image clones behind the cursor as it moves across the wrapped surface. Each image cycles through the supplied list in order, picks up a small random rotation, and fades out after a configurable lifetime; a hard cap on the number alive at once keeps the DOM bounded regardless of cursor velocity.

Pairs well with portfolio openers, gallery entrances, or "scroll to explore" sections.

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>

<TabsContent value="cli">

```bash
npx shadcn@latest add "https://nyxui.com/r/scroll-image-trail.json"
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="scroll-image-trail" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import { ScrollImageTrail } from "@/components/ui/scroll-image-trail";

const IMAGES = ["/gallery/a.jpg", "/gallery/b.jpg", "/gallery/c.jpg"];

export function Example() {
  return (
    <ScrollImageTrail images={IMAGES} className="h-80 w-full rounded-xl">
      <p className="p-12 text-center">move the cursor</p>
    </ScrollImageTrail>
  );
}
```

## Props

| Prop             | Type        | Default | Description                                                                 |
| ---------------- | ----------- | ------- | --------------------------------------------------------------------------- |
| `images`         | `string[]`  | —       | Image URLs to cycle through along the trail.                                |
| `children`       | `ReactNode` | —       | The content inside the interactive area.                                    |
| `imageWidth`     | `number`    | `160`   | Rendered image width in pixels (height auto-scales).                        |
| `distance`       | `number`    | `70`    | Pixels the cursor must move before dropping the next image.                 |
| `maxTrail`       | `number`    | `5`     | Max images alive at once.                                                   |
| `lifetimeMs`     | `number`    | `900`   | How long each image stays before fading out.                                |
| `className`      | `string`    | —       | Extra classes on the outer wrapper.                                         |
| `imageClassName` | `string`    | —       | Extra classes on each trail image (e.g. `aspect-3/4` to crop to one shape). |