Skip to content
English
Border beam comes with Pro. Its preview shows once you unlock it.

How it works

A track is laid over the container: its padding equals the border width and a mask removes the content box, leaving a faint ring. The beam is 12 dots, each moving at constant speed along offset-path: rect(), so length stays constant and the beam bends around corners. A second, blurred copy of the dots runs the same path in a layer masked to the outside of the border, so the head casts a halo on the surface around the container without ever covering its content. Browsers without rect() fall back to a rotating conic gradient.

Use it for

  • The input of an AI assistant or chat entry, to say “ready, start typing”.
  • The recommended plan on a pricing page.
  • The entry card of a new feature, to draw attention for a short time.

Look elsewhere when

  • Several beams on one screen: attention is split, so use at most one.
  • Form errors and warnings: the beam is decorative and cannot express severity; use colour and text.
  • Workspaces people stay on for long: constant motion tires the eye; start it only on focus or hover.

Usage

import { BorderBeam } from './BorderBeam.jsx'

export function PlanCard() {
  return (
    <BorderBeam radius={16} duration={6} colorFrom="#f97316" colorTo="#ec4899" style={{ padding: 20, background: '#fff' }}>
      <h3>Yearly plan</h3>
      <p>$198 / year · 4 free upgrades a month</p>
    </BorderBeam>
  )
}

Props

PropTypeDefaultWhat it does
durationnumber6Seconds per lap.
beamSizenumber90Beam length in px, measured along the border, whatever the container shape.
colorFromstring'#6366f1'Colour of the beam head.
colorTostring'#a855f7'Colour of the beam tail, which then fades to transparent.
borderWidthnumber1.5Border width in px. The container's inner padding must be larger.
radiusnumber16Corner radius in px, shared by the container and the beam track.
reversebooleanfalseCircles counter-clockwise.
delaynumber0Animation delay in seconds. With several beams on screen, use negative values to stagger the start.
glowbooleantrueAdds a soft halo outside the border that follows the beam head. It is masked to the outside of the container, so it never covers the content.
childrenReactNode—Container content. The container sets no background or shadow; use style or className.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root <div>.

Accessibility

  • The track, beam and glow are aria-hidden decoration with pointer-events: none, so clicks and screen readers are unaffected.
  • With reduced motion the beam and glow stop and a static gradient outline is shown, which still marks the element as emphasised.
  • No information depends on the animation.

Motion

One lap takes 6s by default at constant speed (linear, as a loop must). There is no enter or exit animation.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

BorderBeam.jsxborder-beam.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Cards
Animated border card comes with Pro. Its preview shows once you unlock it.
Card lock sheet comes with Pro. Its preview shows once you unlock it.
Envelope open comes with Pro. Its preview shows once you unlock it.