Border Beam

An animated beam of light that travels along the border of its container. Parent needs `relative` and `overflow-hidden`.

Default

Place BorderBeam inside a relative overflow-hidden parent. duration={8} and size={100}.

Loading…

Installation

CLI
npx @sonojs/ui@latest add border-beam
Also needs
npm i motion

Usage

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

export function Example() {
  return (
    <div className="relative h-[500px] w-full overflow-hidden rounded-lg border">
      <BorderBeam />
    </div>
  )
}

Props

PropTypeDefaultDescription
classNamestring-Classes on the moving beam (e.g. via color stops).
sizenumber50Beam square size in pixels.
durationnumber6Loop duration in seconds.
delaynumber0Start delay in seconds (applied as a negative delay).
colorFromstring"#ffaa40"Gradient start color.
colorTostring"#9c40ff"Gradient mid color.
transitionTransition-Override motion transition (e.g. spring).
styleReact.CSSProperties-Inline styles on the beam.
reversebooleanfalseReverse travel direction along the border.
initialOffsetnumber0Starting offset along the path (0–100).
borderWidthnumber1Visible border width of the beam mask in pixels.