# Border Beam

> React border beam: a light that travels around any card's border, drawn as a masked conic gradient in your accent colors. Pauses for reduced motion.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/border-beam
- Source (registry JSON with the full file): https://ui.minidev.pro/r/border-beam.json
- License: MIT. One file, yours to edit after install.

## When to use

Wrap a card, input or pricing tier with it. The beam is a rotating conic gradient masked to the border ring, so the content inside is untouched; it animates transform only and holds still for reduced motion. Set `radius` to match the child's corner radius. For light flowing between elements use AnimatedBeam; for a static highlight use a `border-accent` ring.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/border-beam
```

Writes `components/ui/border-beam.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/border-beam.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { BorderBeam } from "@/components/ui/border-beam"
```

From the npm package:

```tsx
import { BorderBeam } from "minidev-ui-kit/premium/border-beam"
```

## Usage

```tsx
import { BorderBeam } from "@/components/ui/border-beam"

export function Example() {
  return (
    <BorderBeam />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `children` | `React.ReactNode` | - | no |  |
| `duration` | `number` | `6` | no | Seconds per lap. |
| `width` | `number` | `1.5` | no | Border width in pixels. |
| `length` | `number` | `0.18` | no | Beam length, as a fraction of the lap, 0 to 1. |
| `radius` | `number` | `18` | no | Corner radius in pixels; match the wrapped element. |
| `className` | `string` | - | no |  |

## Examples

### Around a card

Wrap your own card; match its radius to the radius prop and the beam hugs the edge.

```tsx
<BorderBeam radius={16}>
  <div className="w-[320px] max-w-full rounded-[inherit] border border-border bg-surface p-5 shadow-raised">
    <div className="flex items-center justify-between">
      <p className="text-sm font-medium text-fg">Lumen Pro</p>
      <span className="rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg">Recommended</span>
    </div>
    <p className="mt-3 text-3xl font-medium tracking-[-0.04em] text-fg tabular-nums">$24<span className="text-sm text-fg-muted"> / month</span></p>
    <ul className="mt-4 space-y-2 text-sm text-fg">
      <li className="flex items-center gap-2"><CheckIcon className="size-4 text-accent-fg" /> Unlimited invoices</li>
      <li className="flex items-center gap-2"><CheckIcon className="size-4 text-accent-fg" /> Automatic reminders</li>
      <li className="flex items-center gap-2"><CheckIcon className="size-4 text-accent-fg" /> Priority support</li>
    </ul>
    <Button className="mt-5 w-full">Choose Pro</Button>
  </div>
</BorderBeam>
```

### Around an input

A thin, fast beam draws the eye to one field, for example the invite box on an empty team page.

```tsx
<BorderBeam radius={10} width={1} duration={3} className="w-72">
  <Input type="email" placeholder="teammate@northwind.example" aria-label="Invite by email" />
</BorderBeam>
```

### Slow and long

A longer beam on a slower lap reads as a glow rather than a chase; width thickens the ring.

```tsx
<BorderBeam duration={12} length={0.4} width={2} />
```

## Accessibility

- The beam layer is `aria-hidden` and `pointer-events-none`; inputs and buttons inside keep working.
- Only `transform: rotate` animates. Under reduced motion the gradient is drawn but does not move.

## FAQ

### Why does the beam not line up with my card's corners?

Set `radius` to the wrapped element's corner radius in pixels. The default is `18`, so a `rounded-xl` (12px) card needs `radius={12}`. The child should use `rounded-[inherit]` or the same radius.

### Does BorderBeam change the layout of the wrapped element?

No. It wraps the child in a `relative w-fit` box and draws the beam in an absolutely positioned ring masked to `width` pixels, so the child keeps its size. Pass `className="w-full"` when the child should stretch.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Animated Beam](https://ui.minidev.pro/docs/animated-beam/md): Light travels along curved paths from sources into a hub and out to a result, measured from the real DOM. Includes a Beam primitive to connect any two elements.
- [Shimmer Button](https://ui.minidev.pro/docs/shimmer-button/md): A React call to action with a slow band of light sweeping across it, a lit top edge and a press state. Ink or accent tone, renders as a button or a link.
- [Shine Border](https://ui.minidev.pro/docs/shine-border/md): React shine border: a conic gradient sweeps around a card's edge, masked to the border ring so content stays untouched. Colors, duration and width props.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.
- [Cursor Spotlight Panel](https://ui.minidev.pro/docs/cursor-spotlight-panel/md): A panel whose accent radial spotlight follows the cursor, driven by Framer Motion values without re-renders. It shows a still surface for reduced motion.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
