Beams

stable 1.6 kB
<hk-beams>

Rotated linear gradients with a soft falloff, composited additively so overlaps brighten the way real light does rather than stacking as opaque bands. Each beam drifts at its own rate, so the set never lines up into a visible repeat.

#background#canvas#decorative

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
colorstring'#dc2626'Base colour. Any hex the background derives its palette from.
speednumber1Animation multiplier. 0 freezes on the first frame.
opacitynumber1Canvas opacity — these sit behind real content.
pausedbooleanfalseStops the loop without unmounting.
beamsnumber6How many beams.
anglenumber-22Tilt in degrees from vertical.
beamWidthnumber0.1Beam width as a fraction of canvas width.

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-bg-color#dc2626Base hue. Every background derives its palette from it.

Accessibility

  • The canvas is aria-hidden — a decorative layer must never be announced.
  • Under prefers-reduced-motion it paints one frame and never starts the loop.
  • The loop stops when the element scrolls out of view and when the tab is hidden, so an offscreen background costs nothing.
  • Frames run outside the Angular zone, so animating never triggers change detection in the rest of the app.

More in Backgrounds