Animated Beam
ProDraws a curved line between two elements and sends a pulse of light along it.
Installation
pnpm dlx shadcn@latest add @viewport/animated-beam
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| containerRef* | React.RefObject<HTMLElement | null>The `relative` element both nodes live in. | — |
| fromRef* | React.RefObject<HTMLElement | null> | — |
| toRef* | React.RefObject<HTMLElement | null> | — |
| curvature | numberBend of the curve in pixels. Negative bends the other way. | 0 |
| reverse | boolean | false |
| duration | number | 3.2 |
| delay | number | 0 |
| colorFrom | string | "var(--brand)" |
| colorTo | string | "var(--brand-3)" |
| className | string | — |
Accessibility
- Decorative SVG is aria-hidden.
- Recomputes on resize, so it stays attached at every breakpoint.
- Shows the static path under reduced motion.