skip to content
mpkcn

~/components/spotlight

Spotlight

A panel with a soft accent glow that follows the pointer while it hovers, drawn in CSS without re-rendering.

$ uptime

up 42 days, load 0.08

$ git log -1

feat: ship the thing

$ whoami

guest

$ df -h /

41% used

Installation

terminal
npx mpkcn add spotlight
deps:none beyond react· tested with react@19.3.0

Usage

Use it in place of a div around a card or panel. It takes every div prop, and the glow appears while the pointer hovers it.

tsx
import { Spotlight } from "@/components/mpkcn/spotlight";

export function StatCard() {
  return (
    <Spotlight className="border border-mpk-line bg-mpk-bg-soft p-5">
      <p className="font-mpk-mono text-xs text-mpk-dim">$ uptime</p>
      <p className="mt-2 text-mpk-ink">up 42 days</p>
    </Spotlight>
  );
}

The glow is a CSS radial gradient placed from two custom properties, --mx and --my, that are updated on pointer move. React never re-renders while it moves.

Examples

Amber, smaller and stronger

$ uptime

up 42 days, load 0.08

$ git log -1

feat: ship the thing

$ whoami

guest

$ df -h /

41% used

Props

PropTypeDefaultDescription
color"blue" | "amber""blue"Accent the glow is tinted with.
sizenumber360Diameter of the glow circle in px.
strengthnumber0.14Glow strength from 0 to 1 on the dark theme. The light theme uses half.
ignoreReducedMotionbooleanfalseFollow the pointer even when the user prefers reduced motion. Use sparingly.
...propsComponentProps<"div">—Any div prop: className, style, onPointerMove (still called), aria attributes, and so on.

Accessibility

  • The glow layer is aria-hidden and pointer-events: none, behind your content (the wrapper is isolate), so text and clicks are untouched.
  • It reacts to a mouse only. On touch screens (hover: none) and under prefers-reduced-motion: reduce there is no glow, unless ignoreReducedMotion is set.
  • It adds no role and no focus stop: it is a plain div with your content inside.