Animated Beam

Lines that connect icon tiles, each with a highlight travelling from one end to the other, for showing how things flow on a marketing page.

Examples

Hub

Three sources curve into one workspace, which feeds one person.

Pipeline

Straight beams with delays that line up, so each step starts when the previous one arrives.

Two-way sync

Two arcs between the same tiles, one of them reversed.

Installation

npx shadcn@latest add https://ui.ndekocode.dev/r/motion-animated-beam.json

Component API

AnimatedBeam

Draws one beam inside its container. The container needs position: relative.

PropTypeDefaultDescription
containerRefReact.RefObject<HTMLElement>The element the beam is drawn in. It is observed for size changes.
fromRefReact.RefObject<HTMLElement>The node the beam starts from, at its centre.
toRefReact.RefObject<HTMLElement>The node the beam ends at, at its centre.
curvaturenumber0How far the middle of the line bends away from a straight line, in px.
reversebooleanfalseWhether the highlight travels from toRef to fromRef.
durationnumber3Seconds for one trip of the highlight.
delaynumber0Seconds before the first trip.
repeatDelaynumber1Seconds of rest between two trips.
classNamestringClasses for the SVG.

BeamNode

An icon tile that sits above the beams. Renders a <div> and accepts a ref.

PropTypeDefaultDescription
material'keycap' | 'gem''keycap'A neutral key cap, or a gem plate in the primary colour.
size'sm' | 'md' | 'lg''md'40, 48 or 64px, with the icon sized to match.
classNamestringClasses for the tile.

Accessibility and motion

  • The beams are decorative SVG and hidden from assistive technology. Give the container role='img' and an aria-label that says what the diagram shows.
  • The highlight is the primary colour only, over a quiet line in the foreground colour.
  • The highlight travels only while the container is on screen. With reduced motion, the lines stay and the highlight is gone.

Credits

Inspired by the animated beam of UI Layouts, rebuilt on our tokens and motion.