Animated beam
Also called animated connector, data flow lines, or animated SVG path
Curved lines that connect icons, with a glowing pulse traveling along each one to show data moving from apps into a hub and on to a user.
import { useEffect, useId, useState, type RefObject } from 'react';
import { motion, useReducedMotion } from 'motion/react';
type AnimatedBeamProps = {
container: RefObject<HTMLElement | null>;
from: RefObject<HTMLElement | null>;
to: RefObject<HTMLElement | null>;
curve?: number; // px the path bows out from each end
delay?: number; // seconds, to stagger several beams
};
export function AnimatedBeam({
container,
from,
to,
curve = 80,
delay = 0
}: AnimatedBeamProps) {
const gradient = useId();
const reduceMotion = useReducedMotion();
const [path, setPath] = useState('');
useEffect(() => {
const [box, start, end] = [container.current, from.current, to.current];
if (!box || !start || !end) return;
// Join the right edge of `from` to the left edge of `to`, in the
// container's coordinates, and redo it whenever the layout changes.
const measure = () => {
const origin = box.getBoundingClientRect();
const a = start.getBoundingClientRect();
const b = end.getBoundingClientRect();
const [x1, x2] = [a.right - origin.left, b.left - origin.left];
const y1 = a.top + a.height / 2 - origin.top;
const y2 = b.top + b.height / 2 - origin.top;
setPath(
`M ${x1} ${y1} C ${x1 + curve} ${y1}, ${x2 - curve} ${y2}, ${x2} ${y2}`
);
};
const observer = new ResizeObserver(measure);
observer.observe(box);
return () => observer.disconnect();
}, [container, from, to, curve]);
return (
<svg
aria-hidden
fill='none'
className='pointer-events-none absolute inset-0 size-full overflow-visible'
>
<defs>
<linearGradient id={gradient}>
<stop offset='0' stopColor='#60a5fa' />
<stop offset='1' stopColor='#c084fc' />
</linearGradient>
</defs>
<path d={path} stroke='currentColor' opacity={0.15} strokeWidth={2} />
{!reduceMotion && (
<motion.path
d={path}
stroke={`url(#${gradient})`}
strokeWidth={2.5}
strokeLinecap='round'
// Motion normalizes the path to a length of 1. A 0.25 dash with a
// gap longer than the path slides from before the start to past
// the end, so one pulse crosses at a time.
initial={{ pathLength: 0.25, pathSpacing: 2, pathOffset: -0.25 }}
animate={{ pathOffset: 1 }}
transition={{
duration: 1.5,
delay,
repeat: Infinity,
repeatDelay: 1.9,
ease: 'easeInOut'
}}
/>
)}
</svg>
);
}Build an integrations diagram: four 48px app tiles in a column on the left, a 72px hub in the middle, and a 52px user avatar on the right. Connect each app to the hub with a curved SVG path (a cubic Bézier with horizontal tangents at both ends) and the hub to the user with a gentle arc, all as faint 2px gray lines. On each path, animate a glowing blue-to-purple pulse, a dash about a quarter of the path long, from start to end with stroke-dashoffset over 1.5s with ease-in-out. Stagger the inputs by 0.35s, send the output once they arrive, and repeat every 3.4s. Recalculate the paths on resize, hide the drawing from screen readers, and drop the pulses when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
What is Animated beam?
An animated beam draws connector lines between elements, usually several app icons that feed into a central hub and then out to a person or device, and sends a bright pulse along each line. It turns an integrations diagram into something that looks live: you can see where data comes from and where it goes.
Draw the connectors as SVG paths with cubic Bézier curves, computed from the icons' positions, which you measure with getBoundingClientRect and update from a ResizeObserver. For the pulse, normalize a second copy of each path with pathLength="1", give it a short dash and a gap longer than the path, and animate stroke-dashoffset so one bright segment slides from end to end. A gradient stroke, or a wide faint dash under a thin bright one, makes it glow.
Stagger the pulses so the inputs arrive one after another and the output leaves once they land; the order tells the story. Keep the base lines faint, mark the drawing aria-hidden, and describe the flow in text nearby. Under prefers-reduced-motion, show the connectors without the moving pulses.
Often confused with
- SVG line drawing
- Line drawing reveals a path once, as if a pen were drawing it. An animated beam keeps sending pulses along a path that is already there.
Related terms
All termsSVG line drawing
An animation that makes an SVG outline look like it is being drawn by hand, by revealing its stroke from start to end.
Orbit animation
Small icons or dots circling a central element on one or more rings, often used to show the tools a product connects to.
Stagger
Animating a group of items one after another with a small delay between each, so they arrive as a cascade.
Border beam
A short streak of light that travels around the edge of a card or button on a loop, drawing attention to it.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.