axi0motion

Light rays

Volumetric rays pour from an edge; the pointer steers the beam and casts a shadow.

  • element
  • webgl
  • pointer
  • background
  • light
  • hero
  • since 0.2

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

Light rays example

Controls

0.85
1

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>

<axi0-light-rays cover></axi0-light-rays>

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

Options

AttributeDefaultWhat it does
colorautothe light's color (warm white, orange on light pages)
origintopthe edge the light comes from
spread0.85how wide the beam opens, in radians
speed1how fast the rays shimmer
coverfalsefill the nearest positioned parent, behind its content

Accessibility

Decorative: the canvas is hidden from screen readers and takes no pointer events. It starts when it comes near the screen and draws only while on screen in a visible tab. Reduced motion: one still frame. Without WebGL a soft glow stands in.

Size

light-rays.js is 1.6 KB gzip, with gl.js 2.1 KB it needs. A page loads the loader (2.7 KB) and core.js (1.4 KB) once, whatever it uses.