Skip to content
WANCRAFT

E.82Backgrounds & Effects

Connection Beams

Curved SVG beams between nodes with a travelling comet of light — for integration diagrams.

NewReactSVGTailwindintermediate

Overview

Connection Beams draws gently curved SVG paths between BeamNode elements inside a container and sends a comet of gradient light along each one. Nodes register themselves through context and are measured with ResizeObserver, so the beams follow any layout and re-route on resize. The light animates stroke-dashoffset on a normalised pathLength with the Web Animations API, so every pulse takes the same time regardless of beam length, with a configurable stagger between beams. Connect every node to a hub automatically or pass explicit links. Animations pause offscreen and in hidden tabs; reduced motion draws static gradient lines, and a screen-reader list describes the connections.

01Installation

Method 01 · Registry

CLI verified

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

npx shadcn@latest add https://wancraft.my/r/connection-beams.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/connection-beams.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 { ConnectionBeams, BeamNode } from "@/components/ui/connection-beams";

export function ConnectionBeamsExample() {
  return (
    <ConnectionBeams
      className="flex w-full max-w-lg items-center justify-between p-8"
    >
      <BeamNode name="mail" label="Mail" className="size-12">M</BeamNode>
      <BeamNode name="hub" hub label="Hub" className="size-16">H</BeamNode>
      <BeamNode name="data" label="Database" className="size-12">D</BeamNode>
    </ConnectionBeams>
  );
}

03Props

PropTypeDefaultDescription
beams{ from: string; to: string; reverse?: boolean }[]—Explicit links by node name. Omit to connect every node to the hub.
curvaturenumber40Sideways bend of each beam in px; negative bends the other way.
durationnumber2800Time for one pulse to travel a beam, in ms.
staggernumber450Delay between beams, in ms.
reversebooleanfalseSend light from the hub outward (from `to` back to `from`).
beamLengthnumber0.3Comet length as a fraction of the beam (0.05–0.6).
pathWidthnumber1.5Stroke width in px.
fromColorstring"#FF7448"Gradient colour at the start of each beam.
toColorstring"#B6F3D1"Gradient colour at the end of each beam.
describebooleantrueRender a visually hidden list of connections using node labels.
BeamNode.namestring—Unique key referenced by beams (not a DOM id).
BeamNode.hubbooleanfalseMarks the hub for automatic connections.
BeamNode.labelstring—Readable name for the screen-reader description.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the container (relative) or the node.

04Features

  • 01BeamNode registration through context — any layout, any nesting
  • 02ResizeObserver re-routing on container and node resize
  • 03Comet of light on a normalised pathLength: equal timing for every beam
  • 04Per-beam gradient from fromColor to toColor, stagger and reverse
  • 05Automatic hub-and-spoke or explicit links
  • 06Web Animations pause offscreen and in hidden tabs
motion · continuousmotion · staggerinput · viewport

05Accessibility

  • The SVG is aria-hidden; a visually hidden list describes each connection using node labels.
  • Nodes are ordinary elements: give icon-only nodes aria-hidden icons and a label.
  • prefers-reduced-motion replaces the moving light with static gradient lines.
  • Beams never intercept pointer events, so node content stays interactive.