Free · MIT licence · No dependencies

Spotlight Grid Free React component

A background grid that wakes up under the cursor. A soft spotlight reveals bright grid lines around the pointer, and every cell it crosses glows and fades behind it like a trail. Drop your hero or section inside it.

  • React
  • CSS
  • Cursor
  • Background
  • Hero
Spotlight Grid

Get the code

Install in one linenpx shadcn@latest add https://alphenex.com/r/spotlight-grid.json

Works 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 SpotlightGrid from '@/components/alphenex/spotlight-grid';

<SpotlightGrid>
  <h1>Your hero goes here</h1>
</SpotlightGrid>

How the spotlight grid works

The grid is drawn twice with CSS gradients: a faint version everywhere, and a bright version masked with a radial gradient that follows the cursor through two CSS variables. Moving the mouse only updates those variables, so the spotlight costs almost nothing.

The glowing trail is a canvas. Each cell the cursor enters is saved with the time it lit up, and every frame redraws the lit cells with an opacity that falls to zero over the trail length. When the last cell has faded the animation loop stops.

Your content sits on top as children, so the grid works as the background for a hero, a pricing block or a whole section.

Frequently asked questions

Yes. Pass a light background colour and a darker glow colour, and adjust the faint line colour in the CSS file to suit.

Want motion like this on your website?

We design and build custom websites with motion, 3D and SEO built in. Websites from $500.

More free components

Explore our work