Beam

An animated connector between two elements with a glowing pulse that travels along the path.

Overview

Beam draws an SVG path between two DOM elements — both must be inside a common positioned container — and animates a glowing streak (or dot) along it.

The component is aria-hidden and purely decorative; the nodes themselves carry the meaning. Use BeamNode for the round icon endpoints, or pass any ref'd element as fromRef / toRef.

Preview

Customize

Curvature
0
Reverse
Duration
3s
Delay
0s
Pulse Length
0.2
Path Color#52525b
Pulse Colorvar(--primary)
Width
1
Track
Arrow
Gap
6
Shape
Pulse

Installation

Add the component with the CLI. It copies the files in and installs anything they depend on.

npx vinyaas add beam

Usage

import { Beam, BeamNode } from "@/components/ui/beam"; import { useRef } from "react"; export function FlowDiagram() { const containerRef = useRef<HTMLDivElement>(null); const fromRef = useRef<HTMLDivElement>(null); const toRef = useRef<HTMLDivElement>(null); return ( <div ref={containerRef} className="relative flex items-center gap-16 p-8"> <BeamNode ref={fromRef}>A</BeamNode> <BeamNode ref={toRef} highlight>B</BeamNode> <Beam containerRef={containerRef} fromRef={fromRef} toRef={toRef} /> </div> ); }

In practice

A three-step data pipeline diagram showing beams staggered between ingestion, processing, and delivery.

Ingest
Process
Deliver

API

Other attributes for the underlying element are passed through.

NameTypeDefaultDescription
containerRefRefObject<HTMLElement | null>—Positioned element the beam is drawn in. Both ends must be inside it.
fromRefRefObject<HTMLElement | null>—Element the beam starts at.
toRefRefObject<HTMLElement | null>—Element the beam ends at.
curvaturenumber0Bend in px, perpendicular to the line from start to end. Positive bends left of the direction of travel.
reversebooleanfalseRun the pulse from `to` back to `from`.
durationnumber3Seconds for one pulse to cross the path.
delaynumber0Seconds before the first pulse. Use to stagger beams along a flow.
pulseLengthnumber0.2Ray length as a share of the path, 0–1 (`pulse="ray"` only).
pathColorstring"color-mix(in oklch, var(--foreground) 22%, transparent)"Track and arrowhead color. Any CSS color.
pulseColorstring"var(--primary)"Pulse color. Any CSS color.
widthnumber1Track stroke width in px.
track"dotted" | "dashed" | "solid""dotted"Track style.
arrowbooleanfalseArrowhead at the end of the track.
gapnumber6Gap in px between each node's edge and the beam end.
shape"arc" | "curve""arc"arc: bent by curvature. curve: an S-curve that leaves and enters along the main direction.
pulse"ray" | "dot""ray"What travels along the path.

Accessibility

Beam is decorative. The SVG carries aria-hidden="true" and is never announced by assistive technology.

  • Put accessible names and roles on the nodes, not on the beam.
  • The pulse animation is disabled under prefers-reduced-motion.