A field of dark glass tiles that tilt towards the cursor in 3D, catching a coloured light glowing behind them.
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.
Customize
Usage
import { FrostedPanes } from "@/components/motionkit/frosted-panes";
<FrostedPanes
className="h-[32rem]"
>
<h1>Your hero</h1>
</FrostedPanes>Motion
The exact curves this component runs, plotted with Motion's own maths.
Colour drifts
Runs on its own
Glint
Pointer moves
SaaS and product heroes, feature sections, pricing backdrops and sign-up pages that want a crisp, modern glass look without heavy effects.
Three radial gradients drift slowly behind everything. A second copy of them is blurred, brightened and masked to the panes with a repeating SVG tile, a rounded square inset by half the gap, so inside each pane the colour is soft and bright and in the gaps it stays sharp. Another repeating tile draws a fine lit edge round every pane, and a radial highlight tracks the pointer inside the mask, so the panes nearest it catch a glint. However many panes there are, it's one blur and two masks.
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/frosted-panes.jsonnpm install motionSave as components/motionkit/frosted-panes.tsx.
"use client";
import { useRef, type CSSProperties, type PointerEvent, type ReactNode } from "react";
type FrostedPanesProps = {
children?: ReactNode;
/** Three colours drifting behind the glass. */
colors?: [string, string, string];
background?: string;
/** Size of each pane, in pixels. */
cell?: number;
/** Space between panes, where the colour shows sharp. */
gap?: number;
/** How frosted the panes are, in pixels of blur. */
blur?: number;
/** Seconds for the colours to drift round once. */
duration?: number;
/** Panes catch the light where the pointer is. */
interactive?: boolean;
className?: string;
};
/** One pane as a repeating SVG tile: a rounded square inset by half the gap on every side. */
const tile = (cell: number, gap: number, body: string) =>
`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='${cell}' height='${cell}'>${body.replaceAll("$i", String(gap / 2)).replaceAll("$s", String(cell - gap))}</svg>`)}")`;
/**
* A wall of frosted glass tiles over slowly drifting colour. Inside each pane the light is soft and bright; in the
* gaps it shows sharp, and the panes nearest the pointer catch a glint. Pure CSS: one blurred copy of the colour,
* masked to the panes, so it costs the same however many there are.
*/
export function FrostedPanes({
children,
colors = ["#5FAEB4", "#B9C7FF", "#D6A7CE"],
background = "#0C1010",
cell = 84,
gap = 8,
blur = 18,
duration = 20,
interactive = true,
className = "",
}: FrostedPanesProps) {
const ref = useRef<HTMLDivElement>(null);
const [a, b, c] = colors;
const radius = Math.round((cell - gap) * 0.16);
const pane = tile(cell, gap, `<rect x='$i' y='$i' width='$s' height='$s' rx='${radius}' fill='white'/>`);
const rim = tile(
cell,
gap,
`<defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='white' stop-opacity='.5'/><stop offset='.5' stop-color='white' stop-opacity='.06'/><stop offset='1' stop-color='white' stop-opacity='.22'/></linearGradient></defs><rect x='$i' y='$i' width='$s' height='$s' rx='${radius}' fill='none' stroke='url(#g)' stroke-width='1'/>`,
);
const colour = `radial-gradient(38% 50% at 25% 35%, ${a}, transparent 70%), radial-gradient(40% 50% at 75% 40%, ${b}, transparent 70%), radial-gradient(45% 55% at 50% 85%, ${c}, transparent 70%)`;
const masked: CSSProperties = { maskImage: pane, WebkitMaskImage: pane, maskSize: `${cell}px ${cell}px`, WebkitMaskSize: `${cell}px ${cell}px` };
function move(event: PointerEvent) {
if (!interactive || event.pointerType === "touch") return;
const rect = ref.current!.getBoundingClientRect();
ref.current!.style.setProperty("--pane-x", `${event.clientX - rect.left}px`);
ref.current!.style.setProperty("--pane-y", `${event.clientY - rect.top}px`);
ref.current!.style.setProperty("--pane-glint", "1");
}
return (
<div
ref={ref}
data-panes=""
onPointerMove={move}
onPointerLeave={() => ref.current?.style.setProperty("--pane-glint", "0")}
className={`relative isolate overflow-hidden ${className}`}
style={{ backgroundColor: background, "--pane-x": "50%", "--pane-y": "30%", "--pane-glint": "0" } as CSSProperties}
>
<style>{`@keyframes panes-drift{0%,100%{transform:translate(0,0) rotate(0) scale(1)}33%{transform:translate(6%,-4%) rotate(8deg) scale(1.08)}66%{transform:translate(-5%,5%) rotate(-6deg) scale(1.04)}}@media (prefers-reduced-motion:reduce){[data-panes] [data-drift]{animation:none!important}}`}</style>
{/* the colour, sharp: it shows in the gaps between panes */}
<div aria-hidden data-drift="" className="absolute -inset-[15%] -z-30" style={{ backgroundImage: colour, opacity: 0.55, animation: `panes-drift ${duration}s ease-in-out infinite` }} />
{/* the same colour, blurred and brightened, seen only through the panes */}
<div aria-hidden className="absolute inset-0 -z-20" style={masked}>
<div data-drift="" className="absolute -inset-[15%]" style={{ backgroundImage: colour, filter: `blur(${blur}px) saturate(1.3) brightness(1.15)`, animation: `panes-drift ${duration}s ease-in-out infinite` }} />
<div className="absolute inset-0 bg-white/[0.06]" />
<div
className="absolute inset-0 transition-opacity duration-500"
style={{ background: "radial-gradient(220px circle at var(--pane-x) var(--pane-y), rgb(255 255 255 / 0.35), transparent 70%)", opacity: "var(--pane-glint)" }}
/>
</div>
{/* a fine lit edge round every pane */}
<div aria-hidden className="pointer-events-none absolute inset-0 -z-10" style={{ backgroundImage: rim, backgroundSize: `${cell}px ${cell}px` }} />
{children}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Your content, laid over the glass. |
| colors | [string, string, string] | teal, periwinkle, orchid | Colours drifting behind the panes. |
| background | string | "#0C1010" | Colour underneath. |
| cell | number | 84 | Size of each pane, in px. |
| gap | number | 8 | Space between panes, in px. |
| blur | number | 18 | How frosted the panes are, in px of blur. |
| duration | number | 20 | Seconds for the colours to drift round once. |
| interactive | boolean | true | Panes catch the light where the pointer is. |
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.
Nothing beyond 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/frosted-panes.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, the colour stops drifting; the glint still follows the pointer, which only moves when you do.
A field of dark glass tiles that tilt towards the cursor in 3D, catching a coloured light glowing behind them.
A quiet dot grid that lights up in teal around the pointer.
Soft colour glowing through ribbed glass: each rib bends and frosts the light behind it, and one glow leans towards the cursor. CSS only.
Clear thinking