Components

Animated Beam

An animated SVG beam for React that connects two elements with a curved path and sends a thin gradient pulse along it. Ideal for integration diagrams, data-flow illustrations and "how it works" sections; it measures the elements itself and redraws whenever the layout changes.

  • Connects any two refs
  • Curved paths
  • ResizeObserver
  • No re-renders while animating
  • prefers-reduced-motion
Email
Webhooks
Git
Automation hub
Chat
Cloud storage
Database

Installation

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

Usage

integration.tsx
"use client"

import { useRef } from "react"
import { AnimatedBeam } from "@/components/dusk/animated-beam/animated-beam"

export function Integration() {
  const containerRef = useRef<HTMLDivElement>(null)
  const appRef = useRef<HTMLDivElement>(null)
  const apiRef = useRef<HTMLDivElement>(null)

  return (
    <div ref={containerRef} className="relative flex justify-between p-10">
      <div ref={appRef} className="relative z-10 size-12 rounded-full bg-card" />
      <div ref={apiRef} className="relative z-10 size-12 rounded-full bg-card" />
      <AnimatedBeam containerRef={containerRef} fromRef={appRef} toRef={apiRef} curvature={-40} />
    </div>
  )
}

Examples

Two-way traffic

Two beams between the same pair: one bends up, one bends down with reverse and its own colors.fromOffset / toOffset aim at the icons rather than the centre of each block.

Client
Server

Fan-out

One source, several targets. Stagger the pulses with delay and give each beam a different curvature.

Checkout
Billing
Fulfilment
Notifications

API Reference

Render the beam inside the positioned container that holds both elements, and give the elements relative z-10 so they sit above it. Also accepts SVG attributes for the root <svg>.

PropTypeDefaultDescription
containerRefRefObject<HTMLElement>—The positioned element both ends live in. The SVG fills it.
fromRefRefObject<HTMLElement>—Element the beam starts from (its centre).
toRefRefObject<HTMLElement>—Element the beam ends at (its centre).
curvaturenumber0Bend in px, perpendicular to the straight line. Negative bends the other way.
reversebooleanfalseSend the pulse from to back to from.
durationnumber3Seconds for the pulse to travel the beam.
delaynumber0Seconds before the first pulse.
repeatDelaynumber0.6Seconds of rest between pulses.
pathColorstring"#ffffff"Color of the resting track.
pathWidthnumber1.5Stroke width of the track and pulse.
pathOpacitynumber0.1Opacity of the resting track.
gradientStartColorstringvar(--color-primary)Pulse color at the from end.
gradientStopColorstring"#e4e4e7"Pulse color at the to end.
pulseLengthnumber0.25Pulse length as a fraction of the beam (0.05–0.6).
fromOffset{ x?: number; y?: number }—Nudge the start point in px.
toOffset{ x?: number; y?: number }—Nudge the end point in px.

Accessibility

  • The SVG is aria-hidden and ignores the pointer; it never sits on top of interactive content.
  • A beam is decoration. Label the connected elements themselves (visible text, or sr-only text inside icon nodes) so the relationship is conveyed without it.
  • The pulse is driven by a motion value, so React does not re-render while it travels.
  • With prefers-reduced-motion there is no pulse; the beam is drawn as a still gradient line.