Animated Beam
Connect two elements with a curved line and send a pulse of light along it.
Overview
Animated Beam draws a curved path between two elements and sends a light pulse along it. Use it to explain how data moves through a system: sources feeding an assistant, services calling an API, or steps in a pipeline. The path is measured from the elements' boxes and recomputed whenever the container or either node resizes, so layouts can be responsive.
Installation
Usage
import { AnimatedBeam } from "@/components/animated/animated-beam"
const containerRef = useRef<HTMLDivElement>(null)
const fromRef = useRef<HTMLDivElement>(null)
const toRef = useRef<HTMLDivElement>(null)
<div ref={containerRef} className="relative flex justify-between">
<div ref={fromRef} className="z-10">Source</div>
<div ref={toRef} className="z-10">Destination</div>
<AnimatedBeam containerRef={containerRef} fromRef={fromRef} toRef={toRef} />
</div>The container must be positioned. Give the nodes z-10 or a background so the beam passes behind them. Stagger several beams with delay so their pulses don't arrive together.
Accessibility
The beam is decorative and hidden from assistive technology, so the diagram's meaning must come from the nodes. Give each node an accessible name, and describe the flow in nearby text when it matters. When reduced motion is requested, the pulse is removed and the resting path stays.