Components

Background Beams

An animated background beams effect for React: thin streaks of light racing along a fan of curved SVG paths, each with a soft tail and a bright head. Seeded so it renders identically on server and client, paused off-screen, and frozen for reduced motion.

  • Background
  • SVG
  • Seeded layout
  • Pauses off-screen
  • Reduced-motion safe

Realtime sync

Changes in your database reach every connected client in under 100 ms.

Installation

$ npx shadcn@latest add https://duskui.com/r/background-beams.json

The beams fill their nearest positioned parent, so give the parent relative and overflow-hidden, and put your content after them with relative so it sits on top.

Usage

hero.tsx
import { BackgroundBeams } from "@/components/dusk/backgrounds/background-beams"

export function Hero() {
  return (
    <section className="relative overflow-hidden">
      <BackgroundBeams />
      <div className="relative">{/* your content */}</div>
    </section>
  )
}

Examples

Color, count & speed

color takes any CSS color. count sets how many paths fan out, speed scales how fast beams travel, and seed picks a different but stable layout.

color="#a5b4fc" count={16}
color="#e5e5e5" speed={1.5}

Call to action

Set pathOpacity to 0 to hide the guide paths and show only moving light, and add a gradient scrim on the text side.

Ready when you are

With pathOpacity=0 only the moving beams show, and a gradient scrim keeps the copy readable.

API Reference

Any other div prop is passed to the root. The SVG stretches to the container with non-scaling strokes, so lines stay crisp at any aspect ratio.

PropTypeDefaultDescription
colorstring"var(--color-primary)"Beam color. Any CSS color.
countnumber10Number of curved paths.
speednumber1Speed multiplier for the beams.
pathOpacitynumber0.05Opacity of the faint guide paths, 0 hides them.
seednumber1Layout seed; the same seed always draws the same beams.
fadebooleantrueFade the beams out toward the edges.
classNamestring—Merged onto the absolutely positioned root.

Accessibility

  • The beams are decorative: they are aria-hidden and pointer-events-none, so they never reach screen readers or block clicks.
  • With prefers-reduced-motion the timeline is frozen on a still frame with a few beams mid-flight.
  • The SVG timeline pauses while the beams are off-screen or the tab is hidden.
  • Keep foreground text on a scrim or card where beams cross it, to maintain contrast.