# Image Trail

> Images that appear and fade along the pointer's path.

Source: https://www.honestui.com/docs/animated/image-trail

```tsx
"use client";

import { ImageTrail } from "@/registry/default/animated/image-trail";

// Abstract artwork tiles, drawn as SVG so the demo needs no network images.
const PALETTES: [string, string, string][] = [
  ["#f4d8c4", "#e07a5f", "#3d405b"],
  ["#d8e2dc", "#84a59d", "#2f3e46"],
  ["#e9e3f5", "#9d8df1", "#1f1b3a"],
  ["#fdf0d5", "#f4a259", "#5b2a1c"],
  ["#dbeafe", "#5b8def", "#0f1c3f"],
  ["#f6e7e7", "#d4708f", "#3a1d2b"],
  ["#e6f2ea", "#52b788", "#1b3a2b"],
  ["#f1efe9", "#b8a88a", "#2b2620"],
];

function tile([paper, accent, ink]: [string, string, string], index: number) {
  const shapes = [
    `<circle cx="160" cy="230" r="120" fill="${accent}"/><circle cx="160" cy="230" r="58" fill="${paper}"/>`,
    `<rect x="40" y="70" width="240" height="260" rx="120" fill="${accent}"/><rect x="40" y="200" width="240" height="130" fill="${ink}" opacity=".85"/>`,
    `<path d="M0 400 L160 90 L320 400 Z" fill="${accent}"/><circle cx="230" cy="110" r="36" fill="${ink}"/>`,
    `<circle cx="110" cy="160" r="90" fill="${accent}"/><circle cx="210" cy="260" r="90" fill="${ink}" opacity=".9"/>`,
    `<rect x="0" y="0" width="160" height="400" fill="${accent}"/><circle cx="160" cy="200" r="80" fill="${ink}"/>`,
    `<path d="M0 260 C80 180 240 340 320 260 L320 400 L0 400 Z" fill="${accent}"/><path d="M0 320 C80 260 240 400 320 320 L320 400 L0 400 Z" fill="${ink}"/>`,
    `<rect x="60" y="60" width="200" height="200" rx="28" fill="${accent}" transform="rotate(12 160 160)"/><circle cx="160" cy="300" r="44" fill="${ink}"/>`,
    `<circle cx="160" cy="200" r="130" fill="none" stroke="${accent}" stroke-width="34"/><circle cx="160" cy="200" r="46" fill="${ink}"/>`,
  ];
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 400"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${paper}"/><stop offset="1" stop-color="${accent}" stop-opacity=".35"/></linearGradient></defs><rect width="320" height="400" fill="${paper}"/><rect width="320" height="400" fill="url(#g)"/>${shapes[index % shapes.length]}</svg>`;
  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
}

const IMAGES = PALETTES.map((palette, index) => tile(palette, index));

export function ImageTrailDemo() {
  return (
    <ImageTrail
      images={IMAGES}
      className="h-[26rem] w-full rounded-xl border border-border bg-background"
    >
      <div className="flex size-full flex-col items-center justify-center gap-2 px-6 text-center">
        <p className="text-sm text-muted-foreground">Studio Field · Selected work 2021–2026</p>
        <p className="text-4xl font-semibold tracking-tight text-foreground sm:text-5xl">Move your cursor</p>
      </div>
    </ImageTrail>
  );
}

```

## Overview [#overview]

Image Trail drops images along the pointer's path as it moves across a section. Each image pops in where the pointer is, holds for a moment, and fades out, so a quick sweep leaves a short trail of work behind it. Use it in a portfolio or studio hero, behind a headline that stays readable on its own.

Three variants are available: `scatter` tilts and offsets each image a little, `stack` tilts them alternately and lets each one drift in the direction of travel, and `fade` keeps them upright and simply fades them.

The component reuses a small pool of images and animates them directly, so moving the pointer does not re-render your React tree.

## Installation [#installation]

<CliBlock commands="[&#x22;image-trail&#x22;]" />

## Usage [#usage]

```tsx
import { ImageTrail } from "@/components/animated/image-trail"

<ImageTrail
  images={["/work/01.jpg", "/work/02.jpg", "/work/03.jpg"]}
  className="h-[28rem]"
>
  <h1>Move your cursor</h1>
</ImageTrail>
```

Images are used in order and repeated. Give the container a height; the trail is clipped to it.

## Accessibility [#accessibility]

Trail images are decorative. They have empty alt text and sit in a layer hidden from assistive technology, so screen readers only meet the children. Put anything people need, such as links to the work itself, in normal content.

With reduced motion enabled the trail is off and only the children show. Touch drags are ignored by default so touch scrolling keeps working; set `touch` to follow drags as well, which also stops the section from scrolling under a finger.

## API Reference [#api-reference]


  ### `images`

type: `(string | { src: string; alt?: string })[]`

Images dropped along the path, in order and repeated.

  ### `children`

type: `ReactNode`

Content shown above the trail.

  ### `variant`

type: `&#x22;scatter&#x22; | &#x22;stack&#x22; | &#x22;fade&#x22;` · default: `&#x22;scatter&#x22;`

How each image enters and leaves.

  ### `threshold`

type: `number` · default: `80`

Pointer travel in CSS pixels between two images.

  ### `duration`

type: `number` · default: `1000`

Milliseconds an image stays, from appearing to gone.

  ### `maxVisible`

type: `number` · default: `8`

Most images on screen at once.

  ### `imageSize`

type: `number` · default: `160`

Image width in CSS pixels.

  ### `aspectRatio`

type: `number` · default: `0.8`

Image width over height.

  ### `touch`

type: `boolean` · default: `false`

Also follows touch drags.

  ### `className`

type: `string`

Class for the container. Set its height here.

  ### `imageClassName`

type: `string`

Class for each image, such as a different radius.
