# Animated Beam

- Page: https://jiguang132.com/resources/magic-ui/docs/animated-beam
- Resource: Magic UI (https://jiguang132.com/resources/magic-ui.md)
- All guides: https://jiguang132.com/resources/magic-ui/docs.md

Install: `npx shadcn@latest add https://jiguang132.com/r/magic-ui/animated-beam.json`

## Use case

Connect referenced DOM elements with an animated SVG beam.

## Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

| Owning component prop | Explanation | Example source |
| --- | --- | --- |
| `Marquee.pauseOnHover` (marquee) | Pause this marquee while hovered. | `examples/bento-demo.tsx` |
| `Marquee.className` (marquee) | Classes on this native component; initialize Tailwind and its required CSS first. | `examples/bento-demo.tsx` |
| `Marquee.children` (marquee) | Native child content; keep the owning component's text/element constraints. | `examples/bento-demo.tsx` |
| `BentoGrid.children` (bento-grid) | Native child content; keep the owning component's text/element constraints. | `examples/bento-demo.tsx` |
| `BentoCard....feature` (bento-grid) | Props spread from an example object: inspect its declaration and native types; the object name is not a prop. | `examples/bento-demo.tsx` |
| `AnimatedBeam.containerRef` (animated-beam) | Reference to the positioned beam container. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-unidirectional.tsx`、`examples/animated-beam-bidirectional.tsx`、`examples/animated-beam-multiple-inputs.tsx`、`examples/animated-beam-multiple-outputs.tsx` |
| `AnimatedBeam.fromRef` (animated-beam) | Reference to the beam's starting DOM element. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-unidirectional.tsx`、`examples/animated-beam-bidirectional.tsx`、`examples/animated-beam-multiple-inputs.tsx`、`examples/animated-beam-multiple-outputs.tsx` |
| `AnimatedBeam.toRef` (animated-beam) | Reference to the beam's ending DOM element. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-unidirectional.tsx`、`examples/animated-beam-bidirectional.tsx`、`examples/animated-beam-multiple-inputs.tsx`、`examples/animated-beam-multiple-outputs.tsx` |
| `AnimatedBeam.curvature` (animated-beam) | Vertical curvature offset of the beam's quadratic path. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-bidirectional.tsx` |
| `AnimatedBeam.endYOffset` (animated-beam) | Pixel offset applied to the beam end's y coordinate. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-bidirectional.tsx` |
| `AnimatedBeam.reverse` (animated-beam) | Reverse the owning effect's motion direction. | `examples/animated-beam-demo.tsx`、`examples/animated-beam-bidirectional.tsx` |
| `AnimatedBeam.duration` (animated-beam) | Native animation duration; numeric/CSS units differ by owner, see source defaults. | `examples/animated-beam-unidirectional.tsx`、`examples/animated-beam-multiple-outputs.tsx` |
| `AnimatedBeam.startYOffset` (animated-beam) | Pixel offset applied to the beam start's y coordinate. | `examples/animated-beam-bidirectional.tsx` |

## Interaction and state checks

- Bento Demo — `bento-demo`
- Animated Beam Demo — `animated-beam-demo`
- Animated Beam Unidirectional — `animated-beam-unidirectional`
- Animated Beam Bidirectional — `animated-beam-bidirectional`
- Animated Beam Multiple Inputs — `animated-beam-multiple-inputs`
- Animated Beam Multiple Outputs — `animated-beam-multiple-outputs`

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

## Business integration boundary

containerRef/fromRef/toRef must resolve within the same document. This visual connection neither transfers data nor invokes an integration.

## Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.


## Available examples

bento-demo, animated-beam-demo, animated-beam-unidirectional, animated-beam-bidirectional, animated-beam-multiple-inputs, animated-beam-multiple-outputs

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.




## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add @magicui/animated-beam
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>



<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Examples

### Animated Beam Uni-Directional



### Animated Beam Bi-Directional



### Animated Beam Multiple Inputs



### Animated Beam Multiple Outputs



## Usage

```tsx showLineNumbers
import { AnimatedBeam } from "@/components/ui/animated-beam"
```

```tsx showLineNumbers
<AnimatedBeam containerRef={containerRef} fromRef={fromRef} toRef={toRef} />
```

## Props

### Animated Beam

| Prop                 | Type      | Default    | Description                                              |
| -------------------- | --------- | ---------- | -------------------------------------------------------- |
| `className`          | `string`  | `-`        | The class name for the component.                        |
| `containerRef`       | `ref`     | `-`        | The container ref.                                       |
| `fromRef`            | `ref`     | `-`        | The ref of the element from which the beam should start. |
| `toRef`              | `ref`     | `-`        | The ref of the element to which the beam should end.     |
| `curvature`          | `number`  | `0`        | The curvature of the beam.                               |
| `reverse`            | `boolean` | `false`    | Whether the beam should be reversed.                     |
| `duration`           | `number`  | `5`        | The duration of the beam.                                |
| `delay`              | `number`  | `0`        | The delay of the beam.                                   |
| `repeat`             | `number`  | `Infinity` | The number of times the beam animation should repeat.    |
| `repeatDelay`        | `number`  | `0`        | The delay between repeated beam animation cycles.        |
| `pathColor`          | `string`  | `gray`     | The color of the beam.                                   |
| `pathWidth`          | `number`  | `2`        | The width of the beam.                                   |
| `pathOpacity`        | `number`  | `0.2`      | The opacity of the beam.                                 |
| `gradientStartColor` | `string`  | `#ffaa40`  | The start color of the gradient.                         |
| `gradientStopColor`  | `string`  | `#9c40ff`  | The stop color of the gradient.                          |
| `startXOffset`       | `number`  | `0`        | The start x offset of the beam.                          |
| `startYOffset`       | `number`  | `0`        | The start y offset of the beam.                          |
| `endXOffset`         | `number`  | `0`        | The end x offset of the beam.                            |
| `endYOffset`         | `number`  | `0`        | The end y offset of the beam.                            |

## Credits

- Credit to [@itsarghyadas](https://twitter.com/itsarghyadas) for figuring out the foundation of this!




## Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

### Bento Demo

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/bento-demo.json
```

Default import: `@/components/magicui/examples/bento-demo`

Dependencies: `@radix-ui/react-icons@1.3.2`, `@radix-ui/react-slot@1.3.0`, `class-variance-authority@0.7.1`, `clsx@2.1.1`, `lucide-react@1.24.0`, `motion@12.42.2`, `react-day-picker@9.14.0`, `tailwind-merge@3.6.0`

### Animated Beam Demo

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/animated-beam-demo.json
```

Default import: `@/components/magicui/examples/animated-beam-demo`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Animated Beam Unidirectional

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/animated-beam-unidirectional.json
```

Default import: `@/components/magicui/examples/animated-beam-unidirectional`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Animated Beam Bidirectional

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/animated-beam-bidirectional.json
```

Default import: `@/components/magicui/examples/animated-beam-bidirectional`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Animated Beam Multiple Inputs

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/animated-beam-multiple-inputs.json
```

Default import: `@/components/magicui/examples/animated-beam-multiple-inputs`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Animated Beam Multiple Outputs

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/animated-beam/animated-beam-multiple-outputs.json
```

Default import: `@/components/magicui/examples/animated-beam-multiple-outputs`

Dependencies: `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Minimal usage and theme

```tsx
import Demo from '@/components/magicui/examples/bento-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

```

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.


## Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.


```ts
AnimatedBeam({
  className,
  containerRef,
  fromRef,
  toRef,
  curvature = 0,
  reverse = false, // Include the reverse prop
  duration = 5,
  delay = 0,
  pathColor = "gray",
  pathWidth = 2,
  pathOpacity = 0.2,
  gradientStartColor = "#ffaa40",
  gradientStopColor = "#9c40ff",
  repeat = Infinity,
  repeatDelay = 0,
  startXOffset = 0,
  startYOffset = 0,
  endXOffset = 0,
  endYOffset = 0,
})
```



```ts
export interface AnimatedBeamProps {
  className?: string
  containerRef: RefObject<HTMLElement | null> // Container ref
  fromRef: RefObject<HTMLElement | null>
  toRef: RefObject<HTMLElement | null>
  curvature?: number
  reverse?: boolean
  pathColor?: string
  pathWidth?: number
  pathOpacity?: number
  gradientStartColor?: string
  gradientStopColor?: string
  delay?: number
  duration?: number
  repeat?: number
  repeatDelay?: number
  startXOffset?: number
  startYOffset?: number
  endXOffset?: number
  endYOffset?: number
}
```


### Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.


```ts
// AnimatedBeam
curvature = 0

// AnimatedBeam
reverse = false

// AnimatedBeam
duration = 5

// AnimatedBeam
delay = 0

// AnimatedBeam
pathColor = "gray"

// AnimatedBeam
pathWidth = 2

// AnimatedBeam
pathOpacity = 0.2

// AnimatedBeam
gradientStartColor = "#ffaa40"

// AnimatedBeam
gradientStopColor = "#9c40ff"

// AnimatedBeam
repeat = Infinity

// AnimatedBeam
repeatDelay = 0

// AnimatedBeam
startXOffset = 0

// AnimatedBeam
startYOffset = 0

// AnimatedBeam
endXOffset = 0

// AnimatedBeam
endYOffset = 0
```


### Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.


```ts
React.FC<AnimatedBeamProps>
RefObject<HTMLElement | null>
HTMLElement
```

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
