Cursor trail
A lightweight pointer trail made from CSS variables and a few decorative dots, disabled for touch and reduced motion.
[data-sc-effect="cursor-trail"] { --sc-x: 50%; --sc-y: 50%; position: relative; isolation: isolate; }
[data-sc-effect="cursor-trail"]::before,
[data-sc-effect="cursor-trail"]::after { content: ""; position: absolute; z-index: -1; width: 10px; aspect-ratio: 1; border-radius: 50%; left: var(--sc-x); top: var(--sc-y); background: #8b5cf6; transform: translate(-50%, -50%); filter: blur(1px); pointer-events: none; transition: transform 220ms ease, opacity 220ms ease; }
[data-sc-effect="cursor-trail"]::after { width: 34px; background: #155eef; opacity: .2; transition-duration: 500ms; }
@media (prefers-reduced-motion: reduce) { [data-sc-effect="cursor-trail"]::before, [data-sc-effect="cursor-trail"]::after { display: none; } }
const trail = document.querySelector('[data-sc-effect="cursor-trail"]');
trail.addEventListener('pointermove', (event) => { const box = trail.getBoundingClientRect(); trail.style.setProperty('--sc-x', `${event.clientX - box.left}px`); trail.style.setProperty('--sc-y', `${event.clientY - box.top}px`); });