Spotlight Card

Card with a mouse-follow glow, the 21st.dev signature effect.

Spotlight card

Move your mouse over this card. A soft glow follows your cursor.

Tailwind CSS
<div class="spotlight-card relative max-w-sm rounded-3xl border border-slate-200 bg-white p-6 overflow-hidden">
  <div class="spotlight-glow"></div>
  <h3 class="relative text-lg font-bold text-slate-900">Spotlight card</h3>
  <p class="relative mt-2 text-sm text-slate-500">Move your mouse over this card. A soft glow follows your cursor.</p>
</div>
<style>
.spotlight-card { --mx: 50%; --my: 50%; }
.spotlight-card .spotlight-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(240px circle at var(--mx) var(--my), rgba(99,102,241,0.15), transparent 70%);
}
</style>
<script>
document.querySelectorAll('.spotlight-card').forEach(function(card) {
  card.addEventListener('mousemove', function(e) {
    var r = card.getBoundingClientRect();
    card.style.setProperty('--mx', (e.clientX - r.left) + 'px');
    card.style.setProperty('--my', (e.clientY - r.top) + 'px');
  });
});
</script>

Free to use in personal and commercial projects. No attribution required.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Emerald

Use the emerald glow for eco, health, or finance products where green feels on brand.

Emerald spotlight

A fresh green glow for eco and finance products.

Tailwind CSS

Dark

Pick the dark card for dashboards and dev tools; the purple glow reads well on near-black.

Dark spotlight

The glow pops harder on dark surfaces.

Tailwind CSS

Rose

Rose suits beauty, food, and lifestyle brands that want a warmer feel.

Rose spotlight

A warm glow for friendly consumer brands.

Tailwind CSS

About this spotlight card

The spotlight card effect is the hover pattern you have seen on Vercel, Linear, and Resend landing pages. As your cursor moves across the card, a soft radial glow follows it, like a flashlight in the dark. It is subtle, premium-feeling, and surprisingly simple: a radial-gradient positioned with CSS variables that JavaScript updates on mousemove.

This spotlight card effect uses pure CSS for the glow and a few lines of vanilla JavaScript for the tracking. No libraries needed. The glow is pointer-events: none so it never blocks clicks, and the effect degrades gracefully on touch devices where there is no cursor.

Use it for feature cards, pricing tiers, or team grids where you want that extra layer of polish. One tip: keep the glow color matched to your brand. Indigo works on light cards; try a warm amber on dark cards.

Static cards in a feature grid all look the same, and a plain shadow change on hover is forgettable. The spotlight card solves the attention problem: instead of the whole card lighting up uniformly, a soft glow follows the visitor's cursor, so the interface responds to where they are looking right now. You have seen this on Linear and Vercel landing pages, where it makes a grid of cards feel alive without any single card shouting. Without it, feature grids blur together and nothing invites the mouse to explore.

This element builds the effect with a radial gradient painted through CSS variables. The glow layer is an absolutely positioned div with background: radial-gradient(240px circle at var(--mx) var(--my), rgba(99,102,241,0.15), transparent 70%). The layer is stacked behind the content and ignores pointer events, so text stays clickable while the light moves beneath it. A mousemove listener on each card reads getBoundingClientRect, converts the cursor position into pixels relative to the card, and writes them into --mx and --my with style.setProperty.

Tune the 240px radius to change the mood: 140px feels like a penlight, 320px washes the whole card. Keep the alpha at 0.15 on light cards and raise it to 0.25 on dark cards so the glow reads clearly. Match the glow hue to the card's accent color rather than defaulting to indigo everywhere; a warm amber glow on a dark card feels intentional, while indigo on everything feels templated.

The most common mistake is attaching one mousemove listener to the window and pushing the coordinates through framework state, which re-renders the card on every mouse movement and tanks performance. The fix is what this snippet does: a small listener per card that writes directly to the element's style, bypassing re-renders entirely. CSS variables were made for exactly this kind of high-frequency visual update.

Where to use it

  • ✓ SaaS feature grids
  • ✓ Pricing page tiers
  • ✓ Portfolio project cards
  • ✓ Team member profiles

Customization tips

Change the rgba(99,102,241,0.15) color to match your brand. Increase the 240px radius for a wider glow or reduce it for a tighter spotlight. On dark cards, raise the opacity to 0.25 so the glow reads clearly.

Design notes

When to use

Use it for feature cards, pricing tiers, or team grids where you want a premium hover moment. The cursor-following glow feels like a flashlight in the dark and reads as high-end restraint. A few cards per section is plenty.

What to avoid

Do not use it where there is no cursor, such as touch-first mobile layouts, where the effect never appears. Do not spotlight every card on the page or the premium feel evaporates.

Accessibility

The effect is mousemove-only, so keyboard and touch users must get the full content without it; treat the glow as pure decoration. Respect prefers-reduced-motion and keep text readable with the glow off.

Frequently asked questions

How does the spotlight card mouse glow work?

A radial-gradient background is positioned with CSS variables (--mx, --my). A mousemove listener updates those variables to the cursor position, so the glow follows the mouse. The glow layer has pointer-events: none so it never intercepts clicks.

Does the spotlight effect work on mobile?

On touch devices there is no hover, so the glow stays centered. The card still looks fine, it just does not react to touch. This is graceful degradation, not a bug.

Can I use the spotlight effect without JavaScript?

The glow itself is pure CSS. You need a few lines of JavaScript only for the cursor tracking. Without it, you can center the glow statically, which still looks good.

How do I make the spotlight effect with CSS variables like --mouse-x?

Listen for mousemove on each card and write the cursor position into --mouse-x and --mouse-y on that card. Then paint a radial-gradient at var(--mouse-x) var(--mouse-y) on a ::before overlay. Using per-card variables keeps every card's glow independent in a grid.

Can I combine a spotlight card with a glowing border?

Yes. Put the radial glow on an absolutely positioned ::before layer, then add a second ::before with padding-box masking so the gradient only shows through a 1px border ring. Both layers read the same --mouse-x and --mouse-y, so the border light tracks the cursor with the fill.

Why is my spotlight card glow laggy on large cards?

Large radial gradients repaint on every mousemove, which is expensive. Throttle the handler with requestAnimationFrame so you write variables at most once per frame. Also keep the glow layer as a separate absolutely positioned element instead of repainting the whole card background.

Customize it with our tools