StealThis .dev

Animated Beam

SVG animated beam/line connecting two elements with a flowing dash animation, perfect for flow diagrams and connection visualizations.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Animated Beam

An SVG animated beam/line that connects two DOM elements with a flowing dash animation. Ideal for flow diagrams, connection visualizations, and interactive node-based UIs.

How it works

  1. JavaScript calculates the center positions of two elements
  2. An SVG path is drawn between them with a cubic bezier curve
  3. stroke-dasharray and stroke-dashoffset are animated via CSS keyframes
  4. A gradient along the path creates the “beam” illumination effect

Customization

  • Change beam color via --beam-color
  • Adjust curvature with the curvature parameter
  • Control animation speed with --beam-dash-speed

When to use it

  • Flow diagrams and architecture visualizations
  • Connecting UI cards or nodes
  • Animated decorative connections between sections