BorderBeam

A beam of light that travels round the border of a card or container.

Installation

bash
npx @smicolon/cli add border-beam

Run init once per project before adding components. See Installation.

Preview

Autumn sale ends tonight

Up to 30% off linen and wool.

Static glowing border

To highlight a card without motion, use GlowingBorder instead of the beam. It draws a still coloured border with a soft glow close to it.

Autumn sale ends tonight

Up to 30% off linen and wool.

Accessibility

  • The beam is decoration and ignores the pointer; the content inside works as usual.
  • With prefers-reduced-motion set, the beam is replaced by a still border at half strength.

Props

PropTypeDefaultDescription
childrenReactNode—Content inside the border.
durationnumber4Seconds for one lap.
borderWidthnumber2Width of the beam in pixels.
colorFromstring"var(--primary)"Colour at the head of the beam.
colorTostring"transparent"Colour the beam fades to.
delaynumber0Seconds before it starts.
GlowingBorder{ glowColor, borderRadius, intensity: "sm" | "md" | "lg" }—A still coloured border with a tight glow.
classNamestring—Extra classes for the component.

Usage

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

<BorderBeam className="rounded-xl" duration={3}>
  <div className="p-6">Autumn sale ends tonight</div>
</BorderBeam>

<GlowingBorder glowColor="var(--chart-2)" intensity="lg">
  <div className="p-6">Autumn sale ends tonight</div>
</GlowingBorder>