Skip to content

Paint Trail

A copy-paste cursors component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

CursorsHTMLJavaScriptCSSany framework
Move your cursor

Copy into your project

HTML
<div class="nuda-cur2-paint-trail">
  <span class="nuda-cur2-paint-trail__seg"></span>
  <span class="nuda-cur2-paint-trail__seg"></span>
  <span class="nuda-cur2-paint-trail__seg"></span>
  <span class="nuda-cur2-paint-trail__seg"></span>
  <span class="nuda-cur2-paint-trail__seg"></span>
  <span class="nuda-cur2-paint-trail__label">Move your cursor</span>
</div>
JavaScript
/* Paint Trail — a chain of segments lags behind the pointer at
   staggered transition speeds (set in CSS), creating a brush-like trail. */
(function () {
  document.querySelectorAll('.nuda-cur2-paint-trail').forEach(function (area) {
    area.addEventListener('mousemove', function (e) {
      var rect = area.getBoundingClientRect();
      area.style.setProperty('--x', (e.clientX - rect.left) + 'px');
      area.style.setProperty('--y', (e.clientY - rect.top) + 'px');
    });
  });
})();
CSS
.nuda-cur2-paint-trail {
  --x: 110px;
  --y: 60px;
  position: relative;
  width: 100%;
  max-width: 220px;
  height: 120px;
  margin: 0 auto;
  border-radius: 12px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
}

.nuda-cur2-paint-trail__seg {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e4ff54;
  transform: translate(var(--x),var(--y)) translate(-50%,-50%);
  transition: transform linear;
  will-change: transform;
  pointer-events: none;
}

.nuda-cur2-paint-trail__seg:nth-child(1) {
  opacity: 1;
  transition-duration: .05s;
}

.nuda-cur2-paint-trail__seg:nth-child(2) {
  opacity: .75;
  transition-duration: .12s;
  width: 12px;
  height: 12px;
}

.nuda-cur2-paint-trail__seg:nth-child(3) {
  opacity: .55;
  transition-duration: .19s;
  width: 10px;
  height: 10px;
}

.nuda-cur2-paint-trail__seg:nth-child(4) {
  opacity: .35;
  transition-duration: .26s;
  width: 8px;
  height: 8px;
}

.nuda-cur2-paint-trail__seg:nth-child(5) {
  opacity: .18;
  transition-duration: .33s;
  width: 6px;
  height: 6px;
}

.nuda-cur2-paint-trail__label {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  color: #777;
  font-size: 11px;
  pointer-events: none;
}

@media (prefers-reduced-motion:reduce) {
  .nuda-cur2-paint-trail__seg {
    transition: none;
  }
}

How to use Paint Trail

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More cursors components

← Browse all NudaUI components