Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/y2k-web/llms.txt
Use this file to discover all available pages before exploring further.
CursorTrail is a purely decorative overlay that sprinkles hot-pink ✦ sparkle particles wherever the mouse moves. Each sparkle springs into existence at full opacity and scale, then fades out while drifting slightly downward and sideways over 0.8 seconds — the kind of whimsical cursor magic you’d find on a mid-2000s fan shrine or DeviantArt profile page. The effect is powered by Framer Motion’s AnimatePresence so entries and exits are smoothly orchestrated without any manual cleanup logic.
Behavior
- Event listener — the component attaches a
mousemovelistener towindowon mount and removes it on unmount, keeping side-effects contained. - Spawn rate — a sparkle is only created on roughly every other
mousemoveevent (50% random chance), which prevents flooding the DOM during fast mouse sweeps while still keeping the trail feeling continuous. - Rolling buffer — the component maintains a state array capped at the last 15 sparkles. Once the cap is reached, the oldest entry is dropped each time a new one is added.
- Exit animation — each sparkle fades its
opacityto0, shrinks itsscaleto0, and drifts+20 pxdownward plus a small random horizontal offset over0.8 swith aneaseOutcurve, giving the impression that the glitter is briefly floating before vanishing.
Props
CursorTrail accepts no props. All state (the sparkle buffer, the event listener lifecycle) is managed entirely inside the component.
Import and Usage
The component is exported asS from Primitives.js. Import it under an alias and drop it once inside App — outside the router outlet or main content area so it sits as a global overlay:
fixed and pointer-events-none it has no impact on layout or interaction — you can safely place it anywhere in the tree.
Framer Motion Animation Config
Each sparkle is amotion.div wrapped inside AnimatePresence. The animation is configured directly on the element via initial, animate, exit, and transition props:
left: -4, top: -4 offset centres the 8 px ✦ glyph on the exact cursor coordinates stored in sparkle.x / sparkle.y.
Accessibility: prefers-reduced-motion
Inside the useEffect that wires up the mousemove listener, the component checks the user’s motion preference before doing anything:
useEffect returns early without attaching any listener. The fixed overlay div is still mounted (it’s pointer-events-none and contains no children), but no sparkle particles are ever created and no animation overhead is incurred. This ensures the site remains comfortable for users who are sensitive to motion or who have explicitly requested a calmer experience.
The
CursorTrail wrapper element is position: fixed and z-[9999] with pointer-events: none. This means it floats above every other element on the page but is completely transparent to all mouse and touch events — clicks, hovers, text selection, and drag interactions all pass straight through to the content beneath it.