Skip to content
Pixelbits
Docs / Cursor trail
Signature

Cursor trail

Small pixel squares that trail the mouse: each one shrinks toward its center and fades out in pixel steps, snapped to a grid. Fast moves are filled in along the path, so the trail never breaks into gaps. One fixed <canvas> that only animates while squares are alive; off on touch screens and under reduced motion. Purely decorative.

Installation

npm: import
import { CursorTrail } from "pixelbits/cursor-trail";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/cursor-trail.json

API

<CursorTrail>

Small pixel squares that trail the mouse: each one shrinks toward its center and fades out in pixel steps, snapped to a grid. Fast moves are filled in along the path, so the trail never breaks into gaps. One fixed <canvas> that only animates while squares are alive; off on touch screens and under reduced motion. Purely decorative.

Example
// once, e.g. in the layout of a landing page
<CursorTrail />
PropTypeDefaultDescription
sizenumber6

Square size in CSS px; positions snap to this grid.

lifenumber420

How long a square lives, in ms.

colorstring"var(--pb-accent)"

Square color; any CSS color.

classNamestring—

Extra classes for the canvas (e.g. a z-* utility to change its layer).