Animated Beam
Web (React)
A dynamic SVG beam animation that traces paths between elements.
A beautiful component that shoots a glowing gradient pulse along an SVG path connecting two HTML elements. It mathematically calculates the path curves automatically based on the live geometry and position of the DOM nodes using ResizeObserver.
💻
📦
🚀
☁️
Installation
CLI
npx @modus-ui/cli add animated-beamManual
- Copy the code from the component tab.
- Create a file at
components/ui/animated-beam.tsx. - Paste the code.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
containerRef | RefObject<HTMLElement | null> | - | The container both elements sit in. |
fromRef | RefObject<HTMLElement | null> | - | The element the beam starts at. |
toRef | RefObject<HTMLElement | null> | - | The element the beam ends at. |
curvature | number | 0 | Bend of the path in pixels. |
reverse | boolean | false | Runs the beam from end to start. |
duration | number | 3 | Seconds for one beam pass. |
delay | number | 0 | Seconds before the beam starts. |
pathColor | string | "hsl(var(--border))" | Colour of the static path. |
gradientStart | string | "hsl(var(--primary))" | Start colour of the beam. |
gradientStop | string | "hsl(var(--primary))" | End colour of the beam. |
Comments