Skip to content
WANCRAFT

E.199Backgrounds & Effects

Electric Arc

Crackling electric arcs between anchors: forked, flickering bolts that re-route constantly and reach for a nearby pointer.

NewReactCanvasTailwindadvanced

Overview

Electric Arc wires a set of anchors together (a minimum spanning tree, so every terminal is connected) and fires lightning along each link. Every bolt is built by recursive midpoint displacement with optional forks, re-routes ten to twenty times a second, and glows through additive stroke layers — a wide faint halo, a mid glow and a bright core — with no blur filters. Arcs strike, crackle for a moment and rest on individual timers; move a pointer near an anchor and it arcs to the cursor. Strikes are rate-limited across the whole canvas to under three per second and the background never flashes. Bolts live in each arc's local frame, so resizing keeps them attached. The canvas is DPR-aware, pauses offscreen and in hidden tabs, deepens the colour on light themes, and reduced motion draws a still, seeded arc diagram.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/electric-arc.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/electric-arc.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/electric-arc.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { ElectricArc } from "@/components/ui/electric-arc";

export function ElectricArcExample() {
  return (
    <div className="relative h-80 w-full overflow-hidden rounded-xl bg-zinc-950">
      <ElectricArc />
    </div>
  );
}

03Props

PropTypeDefaultDescription
intensitynumber0.6Brightness, thickness and strike frequency, 0.1–1.
branchingnumber0.35How many forks split off each bolt, 0–1.
colorstring"#8DB8FF"Arc colour (any CSS colour); deepened automatically on light themes.
nodesnumber5Anchors in the default zig-zag layout (2–12). Ignored when anchors is set.
anchors{ x: number; y: number }[]—Custom anchor positions as 0–1 fractions of the container; they are wired by a minimum spanning tree.
reachnumber200Distance in px within which the nearest anchor arcs to the pointer; 0 disables pointer arcs.
showAnchorsbooleantrueDraw the anchor terminals (they glow while an arc is attached).
childrenReactNode—Optional content layered above the arcs.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root, which is absolute inset-0 — place it inside a positioned parent.

04Features

  • 01Recursive midpoint-displacement bolts with forks, re-routing 10–20 times a second
  • 02Additive glow from layered strokes (halo, glow, core) — no per-frame blur filters
  • 03Anchors wired by a minimum spanning tree; custom anchors as fractions of the container
  • 04The nearest anchor arcs to a mouse or pen pointer within reach (touch: while pressed)
  • 05Flash safety: under 3 strikes per second across the canvas, and the background never flashes
  • 06Time-based timers (same crackle at 60–144Hz), DPR-aware canvas, ResizeObserver, pauses offscreen and in hidden tabs
motion · continuousinput · pointerinput · viewport

05Accessibility

  • The canvas is aria-hidden and ignores pointer events; layered content stays fully interactive.
  • Strike onsets are rate-limited globally to one per 340ms (under the WCAG 2.3.1 three-flashes threshold); only thin lines change, never the whole area.
  • prefers-reduced-motion draws a single still, seeded arc diagram: no flicker, strikes or pointer arcs.
  • On light themes the colour is deepened so arcs keep contrast against pale backgrounds.

06Limitations

  • Decorative only — it conveys no information and has no keyboard interaction.
  • Anchor wiring is a spanning tree, so there are no closed loops between anchors.