Skip to content

Animated Beam

Motion

Light travels along curved paths from sources into a hub and out to a result, measured from the real DOM. Includes a Beam primitive to connect any two elements.

src/registry/premium/animated-beam.tsx/r/animated-beam.json

Installation

bash
npx shadcn@latest add @minidev/animated-beam

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/animated-beam.json

Usage

tsx
import { AnimatedBeam } from "@/components/ui/animated-beam"

export function Example() {
  return (
    <AnimatedBeam />
  )
}

Exports AnimatedBeam Beam

API reference

AnimatedBeam props
PropTypeDefault
inputsSources on the left, each joined to the hub by a beam. Labels must be unique.Node[][ { icon: MailIcon, label: "Email" },...
hubThe centre node, drawn larger in ink.Node{ icon: BotIcon, label: "Agent" }
outputThe node on the right that the hub flows into.Node{ icon: UserIcon, label: "Customer" }
classNamestring-

When to use

Paths are measured from the real DOM, so the diagram reflows with its container. AnimatedBeam is a ready-made "inputs → hub → output" diagram; Beam is the primitive that connects any two refs in your own layout. Use it for integration and pipeline diagrams; for a lit box outline use BorderBeam instead. Reduced motion keeps the static path and drops the light.

Accessibility

  • Every beam SVG is aria-hidden. AnimatedBeam adds an sr-only sentence built from the labels, such as "Email, Chat, Docs, CRM flow into Agent, which responds to Customer." With Beam alone, describe the diagram yourself.
  • Under reduced motion the travelling light is not rendered. The static grey path stays, so the connections are still visible.

Frequently asked questions

How do I draw a beam between my own elements?

Use the exported Beam primitive with three refs: container, from and to. Give the container className="relative", because the SVG is placed over it with absolute inset-0. Each beam runs from the centre of one element to the centre of the other.

Why doesn't the beam follow an element that moves?

Paths are measured on mount, one frame later, and whenever the container resizes (a ResizeObserver on container). A node that moves without the container changing size, for example during a transform animation, keeps the old path until the next resize.

How do I stagger several beams or send data the other way?

Give each Beam a growing delay in seconds and the same duration. reverse runs the pulse from to back to from, and curvature bends the path in pixels (positive bends up, negative bends down). AnimatedBeam itself staggers its inputs by 0.35s.

Dependencies

npm

lucide-reactmotion

Built from

No other MiniDev files

Examples

Custom nodes

inputs, hub and output each take a lucide icon and a label; the paths are measured from the DOM, so any count of inputs works.

Beam primitive

Connect any two refs inside a relative container; curvature bends the path upward in pixels and duration sets one pass.

Two-way sync

Two beams between the same refs with opposite curvature and reverse on one of them read as data flowing both ways.

All Animated React components