Skip to content
IndexRequest a UIAboutContact

Cursor Trail Fade

Move a pointer or finger across the box and a trail fades behind it, as dots or a comet line.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Abstract motion graphic of a glowing comet trail drawn by a moving cursor across a dark navy canvas, a bright white head with a long tapering tail that fades through cyan to transparent, smooth looping figure-eight path, soft glow, a few faint dots left behind along the curve, minimal and elegant, high contrast. Variants: a trail of separate shrinking dots and a short thin ribbon. Negative: clutter, hard edges, text, logos, noise. Reduced motion: single still frame of the trail.

About this pattern

Definition

A cursor trail records recent pointer positions and draws them with fading size or opacity, so motion leaves a short-lived path. It gives direction and speed at a glance and adds playfulness, but it must stay light and never block the content.

Purpose & UX principles

  • Store points with timestamps and draw only those younger than the tail length.
  • Fade by age: older points smaller and more transparent.
  • Use pointer events so mouse, pen and touch work the same; set touch-action: none on the area.
  • Keep it short, around 300 to 600 milliseconds.

Interaction states

  • Two style buttons, a Tail slider and an automatic demo path until you move.

Motion specification

  • Points live for the chosen tail time and fade smoothly.
  • Reduced motion: the trail is turned off and a message is shown.

Responsive behaviour

  • Do not use trails on text-heavy pages; they distract and cost performance.
  • Respect reduced motion by turning the trail off.

Code

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Style"><button data-p="0" aria-pressed="true">Comet</button><button data-p="1" aria-pressed="false">Dots</button></div><canvas id="cv" width="330" height="130" aria-label="Pointer trail area"></canvas><label class="rw">Tail <b id="tv">450 ms</b><input id="tl" type="range" min="150" max="900" value="450"></label><p class="out" id="out"></p></div>

Related patterns

Spring Follow

↗
Spring FollowMotion & Transitions

Magnetic Button

↗
Magnetic ButtonButtons & Actions

Pointer Parallax Layers

↗
Pointer Parallax LayersMotion & Transitions