axi0motion

Lightning

A crackling, branching bolt bends toward the pointer and strikes where you click.

  • element
  • webgl
  • pointer
  • click
  • background
  • electric
  • 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

Lightning example

Controls

12
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-lightning cover></axi0-lightning>

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

Options

AttributeDefaultWhat it does
colorautothe bolt's color (blue white, deep blue on light pages)
rate12how many times a second the bolt changes shape
speed1how fast it flickers
coverfalsefill the nearest positioned parent, behind its content

Accessibility

Decorative: the canvas is hidden from screen readers and takes no pointer events (clicks still reach the content). With no pointer near, the bolt wanders on its own. Frames run only on screen in a visible tab. Reduced motion: one still bolt, no flicker. The flicker stays well under three flashes a second of high contrast at the defaults; keep rate for the bolt's shape, not for flashing.

Size

lightning.js is 1.7 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.