Animated Beam
A gradient beam that travels between two elements.
pnpm dlx @glinui/cli@latest add animated-beamInstallation
pnpm dlx @glinui/cli@latest add animated-beamCredits. Adapted from Magic UI (MIT, (c) Magic UI). SVG path measurement with Web Animations instead of motion, resize aware anchors, RTL offsets, token colors and reduced motion levels. Attribution details.
Prefer the package?
Usage
The container must be positioned (relative) and contain both anchors. Render the beam after the anchors, with the same refs. The beam draws in the container coordinate space, so avoid transforms on the container.
The three demos use only Phosphor icons, never brand logos.
Engines: the `engine` prop is not applicable. SVG path gradient measured from layout; path driven, engines do not apply.
Reverse
Travel from the right anchor to the left.
<AnimatedBeam containerRef={container} fromRef={a} toRef={b} reverse />Integration hub
Several beams share one container, staggered with delay.
<AnimatedBeam containerRef={container} fromRef={top} toRef={hub} curvature={-40} /><AnimatedBeam containerRef={container} fromRef={bottom} toRef={hub} curvature={40} delay={0.6} /><AnimatedBeam containerRef={container} fromRef={hub} toRef={out} delay={1.2} />Accessibility
- Decorative connector: aria-hidden, not focusable, pointer-events none.
- If the connection carries meaning, state it in text next to the anchors.
- The track keeps its contrast with the line token and never overlaps text.
ARIA Attributes
- `aria-hidden="true"` on the svg
Reduced Motion
At motion level full a gradient segment travels the path. With prefers-reduced-motion or level none or subtle, the beam is a static gradient line. It also pauses offscreen and in background tabs.
Affected properties
stroke-dashoffsetopacityAPI Reference
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
containerRef | React.RefObject<HTMLElement | null> | Yes | - | Positioned ancestor that holds both anchors. |
fromRef / toRef | RefObject<HTMLElement> | - | - | Anchor elements. The beam links their centers. |
curvature | number | No | 0 | Bend in px. Positive bends up. |
reverse | boolean | No | false | Travel from toRef to fromRef. |
pathColor / pathWidth / pathOpacity | string / number / number | - | line token / 2 / 1 | Static track styling. |
gradientStartColor / gradientStopColor | string | - | accent tokens | Beam colors. |
duration / delay / repeatDelay | number | - | 4 / 0 / 0 | Seconds per pass, before the first pass, and between passes. |
beamLength | number | No | 0.35 | Travelling segment as a share of the path. |
startXOffset / startYOffset / endXOffset / endYOffset | number | - | 0 | Anchor offsets in px. X offsets flip in RTL. |
delay | number | No | 0 | Seconds before the first pass. |
duration | number | No | 4 | Seconds for one pass. |
endXOffset | number | No | 0 | Auto-generated from TypeScript source. |
endYOffset | number | No | 0 | Auto-generated from TypeScript source. |
fromRef | React.RefObject<HTMLElement | null> | Yes | - | Auto-generated from TypeScript source. |
gradientStartColor | string | No | "var(--color-accent)" | Auto-generated from TypeScript source. |
gradientStopColor | string | No | "color-mix(in oklab, var(--color-accent) 55%, var(--color-foreground))" | Auto-generated from TypeScript source. |
pathColor | string | No | "var(--line-soft, var(--color-border))" | Track color. Defaults to the soft line token. |
pathOpacity | number | No | 1 | Auto-generated from TypeScript source. |
pathWidth | number | No | 2 | Auto-generated from TypeScript source. |
repeatDelay | number | No | 0 | Seconds to rest between passes. |
startXOffset | number | No | 0 | Auto-generated from TypeScript source. |
startYOffset | number | No | 0 | Auto-generated from TypeScript source. |
toRef | React.RefObject<HTMLElement | null> | Yes | - | Auto-generated from TypeScript source. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { AnimatedBeam } from "@glinui/ui"Dependencies
@glinui/ui@glinui/motionGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/animated-beam.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
AnimatedBeamProps
AnimatedBeamProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
beamLength | number | No | 0.35 | Length of the travelling segment as a share of the path, 0.05 to 1. |
containerRef | React.RefObject<HTMLElement | null> | Yes | - | Positioned (relative) element that contains both anchors. The beam is drawn in it. |
curvature | number | No | 0 | Upward bend of the curve in px. Negative bends downward. |
delay | number | No | 0 | Seconds before the first pass. |
duration | number | No | 4 | Seconds for one pass. |
endXOffset | number | No | 0 | - |
endYOffset | number | No | 0 | - |
fromRef | React.RefObject<HTMLElement | null> | Yes | - | - |
gradientStartColor | string | No | "var(--color-accent)" | - |
gradientStopColor | string | No | "color-mix(in oklab, var(--color-accent) 55%, var(--color-foreground))" | - |
pathColor | string | No | "var(--line-soft, var(--color-border))" | Track color. Defaults to the soft line token. |
pathOpacity | number | No | 1 | - |
pathWidth | number | No | 2 | - |
repeatDelay | number | No | 0 | Seconds to rest between passes. |
reverse | boolean | No | false | Travel from `toRef` to `fromRef`. |
startXOffset | number | No | 0 | - |
startYOffset | number | No | 0 | - |
toRef | React.RefObject<HTMLElement | null> | Yes | - | - |