Glin UI
Decorative / ConnectorAdapted from Magic UIbeta

Animated Beam

A gradient beam that travels between two elements.

Edit on GitHub

Installation

Install from
pnpm dlx @glinui/cli@latest add animated-beam

Credits. 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-dashoffsetopacity

API Reference

PropTypeRequiredDefaultDescription
containerRefReact.RefObject<HTMLElement | null>Yes-Positioned ancestor that holds both anchors.
fromRef / toRefRefObject<HTMLElement>--Anchor elements. The beam links their centers.
curvaturenumberNo0Bend in px. Positive bends up.
reversebooleanNofalseTravel from toRef to fromRef.
pathColor / pathWidth / pathOpacitystring / number / number-line token / 2 / 1Static track styling.
gradientStartColor / gradientStopColorstring-accent tokensBeam colors.
duration / delay / repeatDelaynumber-4 / 0 / 0Seconds per pass, before the first pass, and between passes.
beamLengthnumberNo0.35Travelling segment as a share of the path.
startXOffset / startYOffset / endXOffset / endYOffsetnumber-0Anchor offsets in px. X offsets flip in RTL.
delaynumberNo0Seconds before the first pass.
durationnumberNo4Seconds for one pass.
endXOffsetnumberNo0Auto-generated from TypeScript source.
endYOffsetnumberNo0Auto-generated from TypeScript source.
fromRefReact.RefObject<HTMLElement | null>Yes-Auto-generated from TypeScript source.
gradientStartColorstringNo"var(--color-accent)"Auto-generated from TypeScript source.
gradientStopColorstringNo"color-mix(in oklab, var(--color-accent) 55%, var(--color-foreground))"Auto-generated from TypeScript source.
pathColorstringNo"var(--line-soft, var(--color-border))"Track color. Defaults to the soft line token.
pathOpacitynumberNo1Auto-generated from TypeScript source.
pathWidthnumberNo2Auto-generated from TypeScript source.
repeatDelaynumberNo0Seconds to rest between passes.
startXOffsetnumberNo0Auto-generated from TypeScript source.
startYOffsetnumberNo0Auto-generated from TypeScript source.
toRefReact.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/motion

Generated API Snapshot

Beta

Auto-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

PropTypeRequiredDefaultDescription
beamLengthnumberNo0.35Length of the travelling segment as a share of the path, 0.05 to 1.
containerRefReact.RefObject<HTMLElement | null>Yes-Positioned (relative) element that contains both anchors. The beam is drawn in it.
curvaturenumberNo0Upward bend of the curve in px. Negative bends downward.
delaynumberNo0Seconds before the first pass.
durationnumberNo4Seconds for one pass.
endXOffsetnumberNo0-
endYOffsetnumberNo0-
fromRefReact.RefObject<HTMLElement | null>Yes--
gradientStartColorstringNo"var(--color-accent)"-
gradientStopColorstringNo"color-mix(in oklab, var(--color-accent) 55%, var(--color-foreground))"-
pathColorstringNo"var(--line-soft, var(--color-border))"Track color. Defaults to the soft line token.
pathOpacitynumberNo1-
pathWidthnumberNo2-
repeatDelaynumberNo0Seconds to rest between passes.
reversebooleanNofalseTravel from `toRef` to `fromRef`.
startXOffsetnumberNo0-
startYOffsetnumberNo0-
toRefReact.RefObject<HTMLElement | null>Yes--