LOVABLECURSORBOLTV0REPLITWINDSURFLOVABLECURSORBOLTV0REPLITWINDSURF
Back to library
INTERACTION_153
Animated Noise.
A fine film grain shifts frame to frame over the page. A static grain texture before the trigger; stepping the background position between 8 offsets once always, unless reduced motion is set.
- CATEGORY
- Background
- COMPLEXITY
- Easy
- TECH
- CSS
- PLATFORM
- Both
- PERFORMANCE
- Light
LIVE PLAYGROUND
Film grain
CSS / CSS
/* Animated Noise — A fine film grain shifts frame to frame over the page. */
.animated-noise {
--dur: 800ms;
--ease: steps(8, end);
--stagger: 60ms;
will-change: transform, opacity;
}
.animated-noise > * {
opacity: 0;
transform: translateY(14px);
animation: animated-noise-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* a static grain texture -> stepping the background position between 8 offsets */
@keyframes animated-noise-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.animated-noise > * {
opacity: 1;
transform: none;
animation: none;
}
}React / TSX
import { useEffect, useRef } from "react";
/** Animated Noise — trigger: always, unless reduced motion is set */
export function AnimatedNoise({ 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="animated-noise" 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