Scroll Image Trail

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

ByMihirJaiswalUpdated

Loading...

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

Usage

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

PropTypeDefaultDescription
imagesstring[]—Image URLs to cycle through along the trail.
childrenReactNode—The content inside the interactive area.
imageWidthnumber160Rendered image width in pixels (height auto-scales).
distancenumber70Pixels the cursor must move before dropping the next image.
maxTrailnumber5Max images alive at once.
lifetimeMsnumber900How long each image stays before fading out.
classNamestring—Extra classes on the outer wrapper.
imageClassNamestring—Extra classes on each trail image (e.g. aspect-3/4 to crop to one shape).