Before CSS custom cursors were mainstream, GeoCities webmasters discovered the magic of JavaScript mouse trails — glowing particles that followed your every move and made visitors feel like they’d stumbled into a wizard’s lair.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/retro-webpage/llms.txt
Use this file to discover all available pages before exploring further.
SparkleCursor brings that magic back using Framer Motion’s AnimatePresence, spawning up to 15 colored SVG star particles that swoop, fade, and rotate behind the cursor as it glides across the screen.
Props
SparkleCursor accepts no props. Sparkle colors, timing, and limits are all configured internally.
The component renders a fixed,
pointer-events-none overlay that covers the entire viewport (fixed inset-0 z-50). It will not interfere with clicks or hover states on any underlying element.Usage
Behavior & Animation
Event throttling — Amousemove listener is registered on window inside a useEffect. Sparkle creation is throttled to one sparkle per 50 ms using a timestamp comparison, preventing the array from flooding during fast mouse sweeps.
Sparkle objects — Each sparkle is a plain object { id, x, y, color }:
id— auto-incrementing integer used as the Framer Motion keyx/y—clientX/clientYfrom the mouse event (viewport coordinates)color— randomly chosen from the four-color palette:#06b6d4(cyan),#ec4899(pink),#bef264(lime),#fbbf24(amber)
slice(-15). Older sparkles are evicted naturally as new ones are appended, keeping the array bounded without a manual cleanup loop.
Framer Motion animation — Each sparkle is a motion.div wrapped in AnimatePresence:
| Stage | opacity | scale | x | y | rotate |
|---|---|---|---|---|---|
initial | 1 | 0.5 | cursor x | cursor y | 0° |
animate | 0 | 1.5 | — | cursor y + 20 px | 90° |
exit | 0 | — | — | — | — |
easeOut curve, giving sparkles a natural deceleration as they drift downward and fade.
SVG star shape — Each sparkle renders a 20×20 px SVG containing a single <path> with an 8-pointed star:
motion.div is positioned absolutely with left: -10; top: -10 to center the 20 px star on the exact cursor coordinate.
SparkleCursor depends on Framer Motion (motion, AnimatePresence). Ensure framer-motion is listed in your package.json dependencies before using this component.