Glass Grid Glow Free React component
A grid of frosted glass tiles with a glowing orb trapped behind them. The orb chases your cursor on a soft spring, stretching as it speeds up, and every tile it passes lights up. With no cursor around, it drifts on its own.
Get the code
npx shadcn@latest add https://alphenex.com/r/glass-grid-glow.jsonWorks with any React project through the shadcn CLI. Prefer to paste it yourself? Copy the two files below into components/alphenex/. No Tailwind or animation library needed.
import GlassGridGlow from '@/components/alphenex/glass-grid-glow';
<GlassGridGlow />'use client';
import { useEffect, useRef } from 'react';
import './glass-grid-glow.css';
/**
* GlassGridGlow
* A grid of frosted glass tiles with a glowing orb trapped behind them. The
* orb chases the cursor on a soft spring and the tiles it passes light up.
* With no cursor around, the orb drifts on its own.
*
* Free from Alphenex Lab: https://alphenex.com/lab/glass-grid-glow (MIT)
*/
export default function GlassGridGlow({
cols = 5,
rows = 5,
tile = 64, // tile size in px
gap = 6, // space between tiles in px
color = '#1677ff', // orb colour
orb = 1.8, // orb size, in tiles
className = '',
style,
...props
}) {
const rootRef = useRef(null);
const orbRef = useRef(null);
useEffect(() => {
const root = rootRef.current;
const orbEl = orbRef.current;
if (!root || !orbEl) return undefined;
const tiles = [...root.querySelectorAll('.alx-glass__tile')];
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const width = cols * tile + (cols - 1) * gap;
const height = rows * tile + (rows - 1) * gap;
const pos = { x: width / 2, y: height / 2 };
const vel = { x: 0, y: 0 };
let target = null; // cursor position, or null to drift
let frame = 0;
const start = performance.now();
const loop = (now) => {
const t = (now - start) / 1000;
const goal = target || {
x: width / 2 + Math.cos(t * 0.7) * width * 0.28,
y: height / 2 + Math.sin(t * 1.1) * height * 0.28,
};
vel.x = (vel.x + (goal.x - pos.x) * 0.045) * 0.86;
vel.y = (vel.y + (goal.y - pos.y) * 0.045) * 0.86;
pos.x += vel.x;
pos.y += vel.y;
const stretch = Math.min(0.35, Math.hypot(vel.x, vel.y) / 40);
const angle = Math.atan2(vel.y, vel.x);
orbEl.style.transform = `translate(${pos.x}px, ${pos.y}px) translate(-50%, -50%) rotate(${angle}rad) scale(${1 + stretch}, ${1 - stretch * 0.6})`;
const reach = tile * orb * 0.9;
tiles.forEach((el, i) => {
const cx = (i % cols) * (tile + gap) + tile / 2;
const cy = Math.floor(i / cols) * (tile + gap) + tile / 2;
const lit = Math.max(0, 1 - Math.hypot(cx - pos.x, cy - pos.y) / reach);
el.style.setProperty('--lit', lit.toFixed(3));
});
frame = requestAnimationFrame(loop);
};
const onMove = (e) => {
const rect = root.getBoundingClientRect();
target = { x: ((e.clientX - rect.left) / rect.width) * width, y: ((e.clientY - rect.top) / rect.height) * height };
};
const onLeave = () => {
target = null;
};
if (reduce) {
orbEl.style.transform = `translate(${pos.x}px, ${pos.y}px) translate(-50%, -50%)`;
return undefined;
}
frame = requestAnimationFrame(loop);
root.addEventListener('pointermove', onMove, { passive: true });
root.addEventListener('pointerleave', onLeave);
return () => {
cancelAnimationFrame(frame);
root.removeEventListener('pointermove', onMove);
root.removeEventListener('pointerleave', onLeave);
};
}, [cols, rows, tile, gap, orb]);
return (
<div
ref={rootRef}
className={`alx-glass ${className}`}
style={{
'--alx-glass-tile': `${tile}px`,
'--alx-glass-gap': `${gap}px`,
'--alx-glass-color': color,
'--alx-glass-orb': `${tile * orb}px`,
gridTemplateColumns: `repeat(${cols}, var(--alx-glass-tile))`,
...style,
}}
aria-hidden="true"
{...props}
>
<span ref={orbRef} className="alx-glass__orb" />
{Array.from({ length: cols * rows }, (_, i) => (
<span key={i} className="alx-glass__tile" />
))}
</div>
);
}
/* GlassGridGlow, Alphenex Lab (MIT) */
.alx-glass {
position: relative;
display: inline-grid;
gap: var(--alx-glass-gap, 6px);
isolation: isolate;
touch-action: none;
}
.alx-glass__orb {
position: absolute;
left: 0;
top: 0;
z-index: -1;
width: var(--alx-glass-orb);
height: var(--alx-glass-orb);
border-radius: 50%;
background: radial-gradient(circle at 40% 40%, #7fe3ff 0%, var(--alx-glass-color) 45%, transparent 72%);
filter: blur(6px) saturate(1.3);
pointer-events: none;
will-change: transform;
}
.alx-glass__tile {
--lit: 0;
width: var(--alx-glass-tile);
height: var(--alx-glass-tile);
border-radius: 14px;
background: rgba(255, 255, 255, calc(0.16 + var(--lit) * 0.12));
border: 1px solid rgba(255, 255, 255, calc(0.35 + var(--lit) * 0.5));
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.55),
0 0 calc(var(--lit) * 26px) rgba(64, 160, 255, calc(var(--lit) * 0.55));
-webkit-backdrop-filter: blur(10px) saturate(1.4);
backdrop-filter: blur(10px) saturate(1.4);
}
Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React "GlassGridGlow" component with plain CSS. Render a CSS grid of rounded tiles with backdrop-filter: blur(10px), a translucent white fill and a white border. Behind the tiles, absolutely position a blurred radial-gradient orb. In a requestAnimationFrame loop, move the orb toward the cursor with a spring (velocity += (target − position) × 0.045, then × 0.86 damping); when the cursor leaves, aim it at a slow Lissajous path instead. Stretch the orb along its direction of travel based on speed. For each tile, set a --lit CSS variable from 0 to 1 by its distance to the orb and use it to brighten the border and add a coloured glow. Props: cols, rows, tile, gap, color, orb.How the glass grid glow works
The tiles are a plain CSS grid with backdrop-filter, so whatever moves behind them gets frosted. The orb is a blurred radial gradient sitting under the tiles.
A spring moves the orb toward the cursor every frame, so it lags and overshoots a little like a real object. Its speed stretches it along the direction of travel, which sells the physics.
Each tile gets a --lit value from its distance to the orb, and CSS turns that into a brighter border and a glow. When the cursor leaves, the orb follows a slow looping path so the grid never looks dead.
Frequently asked questions
Want motion like this on your website?
We design and build custom websites with motion, 3D and SEO built in. Websites from $500.