A wall of frosted glass tiles over slowly drifting colour: soft, bright light inside each pane, sharp colour in the gaps, and a glint where the pointer is.
A quiet dot grid that lights up in teal around the pointer.
Customize
Usage
import { DotGlowBackground } from "@/components/motionkit/dot-glow-background";
<DotGlowBackground className="h-80 rounded-2xl">
<p>Move your cursor</p>
</DotGlowBackground>Motion
The exact curves this component runs, plotted with Motion's own maths.
Glow follow
Pointer moves over the area
Developer-tool heroes, feature sections and dashboards. The homepage of this site uses it.
Two dot grids are painted as repeating radial gradients: a faint one everywhere, and a bright teal one above it. The bright grid is masked by a radial gradient centred on the pointer, which eases after it on a spring, so only the dots near the cursor light up.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/dot-glow-background.jsonnpm install motionSave as components/motionkit/dot-glow-background.tsx.
"use client";
import type { ReactNode, PointerEvent } from "react";
import { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring } from "motion/react";
type DotGlowBackgroundProps = {
children?: ReactNode;
/** Distance between dots in pixels. */
gap?: number;
/** Radius of the lit area around the pointer. */
radius?: number;
className?: string;
};
export function DotGlowBackground({
children,
gap = 20,
radius = 180,
className = "",
}: DotGlowBackgroundProps) {
const reduceMotion = useReducedMotion();
const x = useMotionValue(-1000);
const y = useMotionValue(-1000);
// the glow eases after the pointer, unless the user prefers reduced motion
const smoothX = useSpring(x, { stiffness: 300, damping: 40 });
const smoothY = useSpring(y, { stiffness: 300, damping: 40 });
const glowX = reduceMotion ? x : smoothX;
const glowY = reduceMotion ? y : smoothY;
const mask = useMotionTemplate`radial-gradient(${radius}px circle at ${glowX}px ${glowY}px, black, transparent)`;
const dots = (color: string) => ({
backgroundImage: `radial-gradient(${color} 1px, transparent 1px)`,
backgroundSize: `${gap}px ${gap}px`,
});
function handleMove(event: PointerEvent<HTMLDivElement>) {
const rect = event.currentTarget.getBoundingClientRect();
x.set(event.clientX - rect.left);
y.set(event.clientY - rect.top);
}
return (
<div
onPointerMove={handleMove}
onPointerLeave={() => {
x.set(-1000);
y.set(-1000);
}}
className={`relative isolate overflow-hidden bg-[#0C1010] ${className}`}
>
<div aria-hidden className="absolute inset-0 -z-10" style={dots("rgb(255 255 255 / 0.09)")} />
<motion.div
aria-hidden
className="absolute inset-0 -z-10"
style={{ ...dots("rgb(95 174 180)"), maskImage: mask, WebkitMaskImage: mask }}
/>
{children}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| gap | number | 20 | Distance between dots in pixels. |
| radius | number | 180 | Radius of the lit area around the pointer. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/dot-glow-background.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
Nothing moves on its own. With reduced motion on, the glow tracks the pointer with no easing.
A wall of frosted glass tiles over slowly drifting colour: soft, bright light inside each pane, sharp colour in the gaps, and a glint where the pointer is.
A field of dark glass tiles that tilt towards the cursor in 3D, catching a coloured light glowing behind them.
A cone of light from above that sways gently and turns to follow the pointer.
Move your cursor