LOVABLECURSORBOLTV0REPLITWINDSURFLOVABLECURSORBOLTV0REPLITWINDSURF
Back to library
INTERACTION_149
Floating Particles.
Fine dust drifts upward behind the content. Distributed below the visible area before the trigger; drifting each dot upward with its own duration and horizontal sway once in view, looping.
- CATEGORY
- Background
- COMPLEXITY
- Easy
- TECH
- CSS
- PLATFORM
- Both
- PERFORMANCE
- Medium
LIVE PLAYGROUND
CSS / CSS
/* Floating Particles — Fine dust drifts upward behind the content. */
.floating-particles {
--dur: 14s;
--ease: linear;
--stagger: 60ms;
will-change: transform, opacity;
}
.floating-particles > * {
opacity: 0;
transform: translateY(14px);
animation: floating-particles-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* distributed below the visible area -> drifting each dot upward with its own duration and horizontal sway */
@keyframes floating-particles-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.floating-particles > * {
opacity: 1;
transform: none;
animation: none;
}
}React / TSX
import { useEffect, useRef } from "react";
/** Floating Particles — trigger: in view, looping */
export function FloatingParticles({ 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="floating-particles" data-state="out">
{children}
</div>
);
}IF YOU LIKE THIS, STEAL THESE TOO.
STRUCTURE / 56PX
TEXTURE / 3%
INTERACTION_147CSS
Gradient Mesh
Soft overlapping gradients drift behind the content.
Background / MediumView