AMBIENT LIGHT
INTERACTION_013CSS + JS
Mouse Glow
Large ambient light that trails the pointer across a section.
Mouse / MediumView
Grid cells light up around the pointer as it moves. An even low-contrast grid before the trigger; raising cell brightness by distance from the pointer with a masked radius once pointer movement over the section.
/* Interactive Background Grid — Grid cells light up around the pointer as it moves. */
.interactive-background-grid {
--dur: 240ms;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--stagger: 60ms;
will-change: transform, opacity;
}
.interactive-background-grid > * {
opacity: 0;
transform: translateY(14px);
animation: interactive-background-grid-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* an even low-contrast grid -> raising cell brightness by distance from the pointer with a masked radius */
@keyframes interactive-background-grid-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.interactive-background-grid > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Interactive Background Grid — trigger: pointer movement over the section */
export function InteractiveBackgroundGrid({ 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="interactive-background-grid" data-state="out">
{children}
</div>
);
}Large ambient light that trails the pointer across a section.
Layers drift at different depths as the pointer moves.
A wide soft light follows the pointer across a dark section.
A short trail of fading dots follows the pointer.