Back to library
INTERACTION_143

Particle Trail.

Fine particles spawn at the pointer and drift away. An empty canvas before the trigger; spawning up to 3 particles per frame with velocity, gravity and fade once pointer movement.

CATEGORY
Mouse
COMPLEXITY
Advanced
TECH
CSS + JS
PLATFORM
Desktop
PERFORMANCE
Heavy
LIVE PLAYGROUND
STUDIO WORKSELECTED PROJECTSCONTACT
Desktop only
CSS / CSS
/* Particle Trail — Fine particles spawn at the pointer and drift away. */
.particle-trail {
  --dur: 900ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.particle-trail > * {
  opacity: 0;
  transform: translateY(14px);
  animation: particle-trail-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* an empty canvas -> spawning up to 3 particles per frame with velocity, gravity and fade */
@keyframes particle-trail-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .particle-trail > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Particle Trail — trigger: pointer movement */
export function ParticleTrail({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="particle-trail" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

MOVE INSIDE
INTERACTION_012CSS + JS

Custom Cursor

Dot plus trailing ring with contextual labels.

Mouse / MediumView
STUDIO WORKSELECTED PROJECTSCONTACT
Desktop only
INTERACTION_141CSS + JS

Cursor Trail

A short trail of fading dots follows the pointer.

Mouse / MediumView
DISTORT
Desktop only
INTERACTION_145CSS + JS

Cursor Text Distortion

Type bends slightly toward the pointer as it passes.

Mouse / LightView
AMBIENT LIGHT
INTERACTION_013CSS + JS

Mouse Glow

Large ambient light that trails the pointer across a section.

Mouse / MediumView