Spotlight

stable 1.1 kB
<hk-spotlight>

Deliberately not canvas: one radial gradient the GPU can composite, with an optional grid masked to the lit area. The only per-move work is writing two CSS variables, coalesced to one write per animation frame and never entering the Angular zone.

#background#canvas#decorative

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
colorstring'#dc2626'Light colour.
sizenumber320Light radius in px.
opacitynumber1Layer opacity.
gridbooleantrueDraws a grid revealed only inside the light.
gridSizenumber32Grid cell size in px.

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-bg-color#dc2626Base hue. Every background derives its palette from it.
--hk-spot-size320pxLight radius.
--hk-spot-grid32pxGrid cell size.

Accessibility

  • The light and grid layers are aria-hidden; projected content stays in the accessibility tree.
  • No canvas and no JavaScript animation — the browser composites one gradient, so it is the cheapest background here.
  • Pointer writes are coalesced to one per frame and run outside the Angular zone.
  • With no pointer (touch, keyboard) the light rests at centre rather than disappearing.

More in Backgrounds