Animated Beam - Animated Light Path Component

An animated beam of light which travels along a path. Perfect for showcasing integrations, API connections, data flow, and AI workflows on landing pages.

Animated Beam

An animated beam of light which travels along a path. Useful for showcasing the "integration" features of a website, API connections, data flow, and AI workflows.

Installation

npx shadcn@latest add "https://ui-struct.vercel.app/r/animated-beam"

Usage

import { AnimatedBeam } from '@/components/ui/animated-beam';
const containerRef = useRef<HTMLDivElement>(null);
const fromRef = useRef<HTMLDivElement>(null);
const toRef = useRef<HTMLDivElement>(null);
<div ref={containerRef} className="relative">
<div ref={fromRef}>From</div>
<div ref={toRef}>To</div>
<AnimatedBeam
containerRef={containerRef}
fromRef={fromRef}
toRef={toRef}
/>
</div>

Preview

Default (Bidirectional Integration)

A complete integration showcase with icons on both sides connected through a central AI element.

Loading preview...

One to One

Simple beam connecting two elements horizontally.

Loading preview...

Bidirectional

Two beams traveling in opposite directions with curved paths creating an elliptical effect.

Loading preview...

Many to One

Multiple input sources connecting to a central processing node, then to a single output.

Loading preview...

One to Many (with Gradient Colors)

Single input distributing to multiple outputs with custom gradient colors per beam.

Loading preview...

Multiple Beams

Complex network with multiple interconnected beams, staggered animations, and various colors.

Loading preview...

Showcase

A professional integration showcase with styled nodes and gradient beams.

Loading preview...

Props

PropTypeDefaultDescription
containerRefRefObject<HTMLElement>RequiredReference to the container element
fromRefRefObject<HTMLElement>RequiredReference to the start element
toRefRefObject<HTMLElement>RequiredReference to the end element
curvaturenumber0Curve amount of the beam path (negative for up, positive for down)
reversebooleanfalseReverse the animation direction
pathColorstring"gray"Color of the static path
pathWidthnumber2Width of the path stroke
pathOpacitynumber0.2Opacity of the static path
gradientStartColorstring"#ffaa40"Starting color of the animated gradient
gradientStopColorstring"#9c40ff"Ending color of the animated gradient
delaynumber0Animation start delay in seconds
durationnumber2Animation duration in seconds
startXOffsetnumber0X offset for the start position
startYOffsetnumber0Y offset for the start position
endXOffsetnumber0X offset for the end position
endYOffsetnumber0Y offset for the end position
classNamestring""Additional CSS classes

Features

  • SVG-based: Clean, scalable paths with smooth animations
  • Customizable curvature: Create straight or curved beam paths
  • Gradient animation: Smooth animated gradient that travels along the path
  • Multiple beams: Support for complex integration diagrams
  • Staggered animations: Use delay prop for sequential animations
  • Responsive: Automatically updates path on container resize
  • Dark mode compatible: Works with both light and dark themes

Use Cases

Use CaseDescription
Integration PagesShowcase how your product connects with other services
AI WorkflowsVisualize data flow through AI/ML pipelines
API DocumentationIllustrate request/response flows
Data PipelinesShow how data moves through your system
Architecture DiagramsAnimated system architecture visualizations

Tips

  1. Container positioning: The container must have position: relative for beams to render correctly.

  2. Element centering: Beams connect to the center of referenced elements. Use startXOffset/endYOffset props to fine-tune positions.

  3. Curved paths: Use positive curvature values to curve downward, negative values to curve upward.

  4. Multiple beams: Create complex diagrams by adding multiple AnimatedBeam components with different refs and settings.

  5. Staggered animations: Use the delay prop to create sequential beam animations for a more dynamic effect.

  6. Custom colors: Use gradientStartColor and gradientStopColor to match your brand colors.

Code

Loading preview...