StealThis .dev

Magic Card

Card with a radial gradient spotlight that follows the mouse cursor, creating an interactive lighting effect.

Open in Lab
css javascript svelte vue
Targets: TS JS HTML React Svelte Vue

Code

Magic Card

A card where a radial gradient spotlight follows the mouse cursor position, creating an interactive, magical lighting effect that responds to user movement.

How it works

  1. JavaScript listens for mousemove events on the card
  2. The cursor position relative to the card is calculated
  3. CSS custom properties --mouse-x and --mouse-y are updated in real time
  4. A radial-gradient overlay uses these properties to position the spotlight

Customization

  • Change spotlight color with --magic-color (default: rgba(120, 120, 255, 0.15))
  • Adjust spotlight radius with --magic-radius (default: 250px)
  • Multiple cards can be used in a grid — each tracks independently

When to use it

  • Feature showcase grids
  • Interactive card-based navigation
  • Portfolio or project listing pages