WebberUI

Animated Beam

A flowing beam between nodes, well suited to integration diagrams and data-flow animations.

Draws a flowing beam between any two nodes, with the path recalculated automatically as the container resizes — ideal for integration diagrams, data pipelines, and architecture diagrams.

Loading preview…
npx shadcn@latest add https://webberui.com/r/animated-beam.json

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

0
3
2
<AnimatedBeam />

Installation

npx shadcn@latest add https://webberui.com/r/animated-beam.json

Or, once registries are configured in components.json, install it as @webberui/animated-beam.

Usage

The beam is an absolutely positioned overlay that measures coordinates through three refs: containerRef is the measurement origin, and fromRef / toRef are the nodes at each end. Just put the nodes and the beam inside the same relative container.

"use client";

import * as React from "react";
import { AnimatedBeam } from "@/components/ui/animated-beam";

export function Diagram() {
  const containerRef = React.useRef<HTMLDivElement>(null);
  const fromRef = React.useRef<HTMLDivElement>(null);
  const toRef = React.useRef<HTMLDivElement>(null);

  return (
    <div ref={containerRef} className="relative flex justify-between p-10">
      <div ref={fromRef} className="size-11 rounded-full bg-white" />
      <div ref={toRef} className="size-11 rounded-full bg-white" />
      <AnimatedBeam
        containerRef={containerRef}
        fromRef={fromRef}
        toRef={toRef}
      />
    </div>
  );
}

The nodes need real dimensions and positioning; the beam is layered beneath them with -z-10, so make sure the container carries relative. Use different delay values to offset the flow timing of multiple beams, and curvature to spread apart lines that converge on the same hub.

Props

PropTypeDefaultDescription
containerRefRefObject<HTMLElement | null>The outer container used to measure coordinates
fromRefRefObject<HTMLElement | null>The node the beam starts at
toRefRefObject<HTMLElement | null>The node the beam ends at
curvaturenumber0Curvature (px): positive arcs upward, negative dips downward
reversebooleanfalseFlow in reverse (end toward start)
durationnumber3Duration of one pass of the flow (seconds)
delaynumber0Delay before the reveal starts (seconds)
pathColorstring"currentColor"Color of the static base line
pathWidthnumber2Line width (px)
pathOpacitynumber0.15Opacity of the base line
gradientStartColorstring"#818cf8"Start color of the flowing gradient
gradientStopColorstring"#22d3ee"End color of the flowing gradient
startXOffsetnumber0Fine X adjustment for the start point (px)
startYOffsetnumber0Fine Y adjustment for the start point (px)
endXOffsetnumber0Fine X adjustment for the end point (px)
endYOffsetnumber0Fine Y adjustment for the end point (px)

Accessibility

  • When the user has "reduce motion" enabled at the system level, only the static base line remains and the flowing highlight is not played
  • The beam layer carries aria-hidden; it is decorative only, so it does not interfere with assistive technology
  • The path watches the container's size through a ResizeObserver and recalculates automatically in responsive layouts, cleaning up on unmount

On this page