Cursor Effects Animation — Reference
Trailing Cursor
The Trailing Cursor is a CSS animation component that canvas dots that trail behind the cursor, fading out toward the tail. Adjust trail length, follow speed, dot size, and color with the live controls. It ships as self-contained HTML and CSS with no external dependencies, making it drop-in ready for any modern web project regardless of framework or build system.
When to use the Trailing Cursor
- Portfolio sites, creative agencies, and immersive hero sections
- Chat typing indicators, inline loading, and message delivery states
- Component libraries and design systems that need consistent motion patterns
- Progressive enhancement — works in all modern browsers, degrades gracefully
Performance characteristics
- GPU-accelerated — uses CSS transform and opacity so compositing happens off the main thread
- Zero JavaScript dependency in most configurations — no framework, no bundler required
- Approximately 60 fps on any device that supports CSS animations (Chrome 43+, Firefox 16+, Safari 9+)
- Self-contained in a single HTML file — no npm install, no build step, paste and ship
How it compares
Unlike equivalent JavaScript implementations, the Trailing Cursor does not require any runtime library — there is nothing to install, bundle, or load asynchronously.
Compared to animated GIFs or video embeds, this CSS component is resolution-independent, theme-able via CSS custom properties, and weighs a fraction of the equivalent media file.
Source code
CSS
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0f0f0f; cursor: none; }
.hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-family: sans-serif; font-size: 16px; color: #ffffff; opacity: 0.45; pointer-events: none; user-select: none; letter-spacing: 0.04em; }
canvas { position: fixed; top: 0; left: 0; pointer-events: none; }HTML
<p class="hint">Move your cursor here</p>
<canvas id="c"></canvas>Full source
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0f0f0f; cursor: none; }
.hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-family: sans-serif; font-size: 16px; color: #ffffff; opacity: 0.45; pointer-events: none; user-select: none; letter-spacing: 0.04em; }
canvas { position: fixed; top: 0; left: 0; pointer-events: none; }
</style>
</head>
<body>
<p class="hint">Move your cursor here</p>
<canvas id="c"></canvas>
<script>
var N = 15;
var RATE = 0.4;
var COL = '#6366f1';
var SZ = 6;
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var cur = {x: -999, y: -999};
var pts = [];
var initted = false;
function resize() { canvas.width = innerWidth; canvas.height = innerHeight; }
function frame() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (!initted) { requestAnimationFrame(frame); return; }
var x = cur.x, y = cur.y;
pts.forEach(function(p, i) {
var np = pts[i+1] || pts[0];
p.x = x; p.y = y;
var prog = i / pts.length;
ctx.beginPath();
ctx.arc(p.x, p.y, Math.max(0.5, SZ * (1 - prog * 0.65)), 0, Math.PI * 2);
ctx.fillStyle = COL;
ctx.globalAlpha = 1 - prog;
ctx.fill();
x += (np.x - p.x) * RATE;
y += (np.y - p.y) * RATE;
});
ctx.globalAlpha = 1;
requestAnimationFrame(frame);
}
document.addEventListener('mousemove', function(e) {
cur.x = e.clientX; cur.y = e.clientY;
if (!initted) {
initted = true;
for (var i = 0; i < N; i++) pts.push({x: cur.x, y: cur.y});
}
});
window.addEventListener('resize', resize);
resize();
frame();
</script>
</body>
</html>Frequently asked questions
How do I add the Trailing Cursor to my project?
Copy the full source code from the code block on this page. Paste the <style> block into your stylesheet (or a <style> tag in your HTML head) and the HTML markup into your template. No npm install or build step is required — the animation is self-contained. To customize colors, speed, or size, use Grepped's workspace at grepped.dev/animations/cursors/trailing-cursor.
Is the Trailing Cursor free to use?
Yes. All Grepped preset animations are free to use in personal and commercial projects. You may copy, modify, and redistribute the code without attribution. The only limitation is that you may not resell the presets themselves as part of a competing animation library.
Does the Trailing Cursor work on mobile browsers?
Yes. The Trailing Cursor uses standard CSS animations and transforms that are supported in all modern mobile browsers — Chrome for Android, Safari on iOS 9+, Samsung Internet, and Firefox for Android. Where JavaScript is used for interactivity (e.g. cursor effects), it falls back gracefully on touch devices.
Can I customize the Trailing Cursor's colors, speed, or size?
Yes. Open the live customization workspace at grepped.dev/animations/cursors/trailing-cursor to adjust the animation with real-time sliders, color pickers, and toggles — no code required. For deeper changes, the source code uses CSS custom properties (variables) so you can edit them directly in your stylesheet.
Want to customize this animation or generate a new one from a text prompt?
Open in Workspace — it's free