Pixelated Image Trail
A stunning hover effect that creates a trail of images following the cursor with a sliced, pixelated reveal animation. Perfect for creative portfolios, galleries, and immersive landing pages.
Move Your Mouse
Watch the magic unfold
Install using CLI
npx shadcn@latest add "https://vengeance-ui.vercel.app/r/pixelated-image-trail.json"Install Manually
Install dependencies
Add util file
lib/utils.ts
Add the required CSS styles
Add these styles to your globals.css
Copy the source code
Copy the code below and paste it into components/ui/pixelated-image-trail.tsx
Usage
Examples
Fast Animation
Reduced lifespan and quicker transitions for a more dynamic feel.
Fast Mode
Rapid trail with quick transitions
Fine Slices (20)
More slices create a smoother, finer pixelation effect.
Fine Slices
20 slices for smoother transitions
Coarse Slices (5)
Fewer slices create a more dramatic, blocky pixelation effect.
Coarse Slices
5 slices for dramatic effect
Props
| Prop Name | Type | Default | Description |
|---|---|---|---|
| images | string[] | [] | Array of image URLs to cycle through in the trail. |
| slices | number | 10 | Number of horizontal slices for the pixelation effect. |
| spawnThreshold | number | 12 | Distance threshold (px) before spawning a new trail image. |
| smoothing | number | 0.35 | Interpolation factor for mouse smoothing (0-1). Higher = snappier. |
| config.imageLifespan | number | 700 | Duration (ms) before an image starts fading out. |
| config.inDuration | number | 400 | Duration (ms) of the reveal animation. |
| config.outDuration | number | 500 | Duration (ms) of the hide animation. |
| config.staggerIn | number | 18 | Stagger delay (ms) for slices during reveal. |
| config.staggerOut | number | 12 | Stagger delay (ms) for slices during hide. |
| config.slideDuration | number | 450 | Duration (ms) of the slide animation. |
| config.slideEasing | string | "cubic-bezier(0.22, 1, 0.36, 1)" | CSS easing function for slide animation (snappy expo-out). |
| config.easing | string | "cubic-bezier(0.25, 1, 0.5, 1)" | CSS easing function for mask animations (smooth quad-out). |
| className | string | "" | Additional CSS classes for the container. |
Features
Pixelated Reveal Effect: Images reveal through sliced horizontal layers creating a unique pixelated animation
Smooth Cursor Following: Mouse position is interpolated for buttery-smooth trailing
Customizable Slices: Control the number of slices from coarse (5) to fine (20+) for different visual styles
Configurable Timing: Full control over animation durations, stagger delays, and easing functions
Portal Rendering: Uses React Portal to render above all content without z-index issues
Auto Cleanup: Proper memory management with automatic cleanup of trail images
GPU Optimized: Uses translate3d and contain for 60fps performance
Image Preloading: Images are preloaded for instant display without loading delays
Notes
- The component uses
createPortalto render the trail at the root level, ensuring it appears above all other content - For best performance, limit the number of concurrent trail images by adjusting
spawnThreshold - The effect is optimized for mouse interactions on desktop devices
- Images should be square (or close to it) for the best visual effect
- Place your trail images in
/public/trail-images/for the default fallback