Spotlight card
Also called spotlight hover effect or cursor glow
A card whose border and background light up with a soft radial glow that follows the mouse pointer, often across a whole grid of cards.
import type { PointerEvent } from 'react';
type Feature = { title: string; description: string };
export function SpotlightGrid({ features }: { features: Feature[] }) {
// Every card tracks the same pointer, so the glow spills across borders.
// group-hover only applies on devices that can hover, so touch skips it.
function onPointerMove(event: PointerEvent<HTMLDivElement>) {
for (const card of event.currentTarget.children) {
const rect = card.getBoundingClientRect();
const style = (card as HTMLElement).style;
style.setProperty('--x', `${event.clientX - rect.left}px`);
style.setProperty('--y', `${event.clientY - rect.top}px`);
}
}
return (
<div
onPointerMove={onPointerMove}
className='group grid grid-cols-1 gap-4 sm:grid-cols-3'
>
{features.map((feature) => (
// The 1px padding shows the base border and the glowing border layer.
<div
key={feature.title}
className='relative rounded-2xl bg-border p-px'
>
<div
aria-hidden
className='absolute inset-0 rounded-[inherit] bg-[radial-gradient(200px_circle_at_var(--x)_var(--y),var(--color-blue-500),transparent)] opacity-0 transition-opacity duration-300 group-hover:opacity-100'
/>
<div className='relative h-full rounded-[15px] bg-background p-6'>
<div
aria-hidden
className='absolute inset-0 rounded-[inherit] bg-[radial-gradient(200px_circle_at_var(--x)_var(--y),--alpha(var(--color-blue-500)/8%),transparent)] opacity-0 transition-opacity duration-300 group-hover:opacity-100'
/>
<h3 className='relative font-medium'>{feature.title}</h3>
<p className='relative mt-1 text-sm text-muted-foreground'>
{feature.description}
</p>
</div>
</div>
))}
</div>
);
}Add a spotlight effect to the feature grid: on pointermove over the grid, set --x and --y CSS variables on each card to the pointer position relative to that card. Paint a 1px border with radial-gradient(200px circle at var(--x) var(--y), the accent color, transparent) and a faint inner glow at 8% opacity with the same center. Fade the glow out over 300ms when the pointer leaves, and turn it off on touch devices.
Paste into Layerwise or any AI coding tool.
What is Spotlight card?
A spotlight card draws a radial gradient centered on the pointer, so a soft circle of light seems to follow the mouse. In the popular grid version, every card tracks the same pointer, so the glow spills across the borders of neighboring cards as you move, like a flashlight sweeping over a panel.
It is common on feature grids, pricing sections, and dark landing pages. Keep it subtle: a brighter border with a faint inner wash reads as polish, while a strong glow makes text harder to read.
Store the pointer position in CSS variables such as --x and --y and use them inside radial-gradient(), so moving the mouse only updates two values per card. Fade the glow out when the pointer leaves, and skip it on touch screens, where there is no pointer to follow.
Often confused with
- Glow effect
- A glow effect is a soft light around an element that stays put. A spotlight card moves its glow to follow the pointer.
Related terms
All termsHover effect
A visual change, such as a lift, glow, or zoom, that happens when the mouse pointer moves over an element to show it can be clicked.
3D tilt card
A card that tips in 3D as the mouse moves over it, often with a moving glare, so it feels like a physical object in your hand.
Border beam
A short streak of light that travels around the edge of a card or button on a loop, drawing attention to it.
Bento grid
A grid of rounded tiles in mixed sizes that fit together like a bento lunch box, often used to show several features at once.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.