axi0motion

Spotlight card

A soft light follows the pointer across a card.

  • enhancer
  • card
  • hover
  • pointer
  • glow
  • since 0.1

Background Studio: tune it below, then copy the code

Your system asks for reduced motion: the demo shows its final state and nothing moves.

Live demo

Spotlight card example

Spotlight

Move the pointer over this card.

Controls

280 px

Code

It follows the controls above: change an option and the code changes with it.

<link rel="stylesheet" href="/axi0/motion/motion.css?v=6">
<script src="/axi0/motion/motion.js?v=10" defer></script>

<div class="demo-card" data-motion="spotlight">
  <h4>Spotlight</h4>
  <p>Move the pointer over this card.</p>
</div>

The wrappers: Spotlight.tsx (React, TypeScript) and Spotlight.vue (Vue). Both render the same attributes as the HTML; the loader does the rest.

Options

AttributeDefaultWhat it does
data-motion-colorautoany CSS color, best with some transparency; auto is a soft orange glow
data-motion-size280the light's radius in pixels

Accessibility

It moves only with the pointer (no loop). Reduced motion: a still glow in the middle on hover. It uses the card's ::before and sets position: relative on it.

Size

spotlight.js is 0.6 KB gzip. A page loads the loader (2.7 KB) and core.js (1.4 KB) once, whatever it uses.