CSS · one gradient

Spotlight cards

A soft light that follows the pointer across a grid of cards, lighting whichever it is over.

Yours to take. No sign-up, no email, no attribution needed.

The code, in two parts

spotlight.cssCSS
.card {
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .3s ease;
  background: radial-gradient(
    420px circle at var(--mx, 50%) var(--my, 50%),
    rgba(234, 159, 144, .42),
    transparent 46%
  );
}

.card:hover::before { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .card::before { transition: none; }
}
spotlight.jsJS
for (const card of document.querySelectorAll('.card')) {
  card.addEventListener('pointermove', (e) => {
    const r = card.getBoundingClientRect();
    card.style.setProperty('--mx', (e.clientX - r.left) + 'px');
    card.style.setProperty('--my', (e.clientY - r.top) + 'px');
  });
}

We do this for a living, on bigger things.

Tomoe builds operations software for businesses running real money through spreadsheets and WhatsApp threads. The same care that went into this effect goes into an order portal that a warehouse depends on.

Tell us what is going wrong Everything else on the shelf

Review

How is it holding up?

If we built something for you, this is the place to say so — good or otherwise. Your words go up as you wrote them; we do not edit them into marketing copy.

Out of five

0 / 900

We read every review before it goes on the site. Nothing is published automatically.