Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Free

Beams Background for React

Curved beams of light that sweep diagonally behind your content, each drawing itself in a cyan to violet to pink gradient. For React with Base UI, when a SaaS or AI landing page needs a modern, technical hero.

Framework

Twenty curved beams sweep diagonally across the section, each drawing itself from end to end and fading out before it starts again, over faint guide curves. Each beam is an SVG stroke drawn once and uncovered by a sliding window, so the browser's compositor moves it without repainting and nothing runs in JavaScript, and each beam keeps its own 4 to 7.2 second cycle, so they never move in step.

Use it behind a hero or a feature section. For beams that fall and burst on a floor, use Beams Collision; for many monochrome curves with the same drawing motion, Paths; for beams rushing toward you down a tunnel, Warp; for colour light without lines, Aurora.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Usage

import { Beams } from "@/components/ui/beams";

Beams is a container: give it a size and put your content inside. The beams sit behind the content and scale to cover the box.

<Beams className="flex min-h-[420px] items-center justify-center">
  <h1 className="text-5xl font-semibold">Your data, in motion</h1>
</Beams>

For a backdrop behind the whole page, leave it empty and fix it under everything else:

<Beams className="fixed inset-0 -z-10" />

Demos

Theme colours

colors takes up to three CSS colours: the gradient's start, middle and end. Here they're three shades of your theme's primary colour, so the beams follow your brand in light and dark.

Preview width

Speed

speed={0.5} doubles every beam's cycle, for a calmer card.

Preview width

Accessibility

The beams are decorative: they're hidden from screen readers and never take the pointer, and your content stays on top in normal flow. With reduced motion every beam stops where it is, a still pattern of part-drawn curves. The beams are 1px lines at no more than 60% opacity, so text on top stays readable; keep it in your foreground colour. Nothing flashes.

FAQ

What is the motion made of?

Each beam is an SVG curve drawn once. A window slides across it while the layer inside slides back as far, so the stroke stays put and shows from its start to a moving head, and the beam fades in and out. Those are transform and opacity keyframes the install adds to your stylesheet, so the compositor runs them without repainting the SVG. Nothing runs in JavaScript, and it renders the same on the server.

How do I change the colours?

Pass colors with up to three CSS colours: start, middle and end. The default is a fixed cyan, violet and pink that reads on light and dark backgrounds; theme variables such as var(--primary) work too.

Can I put content on top?

Yes: it's a container, so children render above the beams. The SVG is hidden from screen readers and ignores the pointer, so links and buttons on top work as usual.

Can I make it faster or slower?

speed scales every beam's 4 to 7.2 second cycle: 2 is twice as fast, 0.5 half as fast.

Can the beams run the other way?

Flip the layer with *:data-[slot=beams-layer]:-scale-x-100 on the component, and they sweep from top right to bottom left.

Can I have more or fewer beams?

There are always twenty: the curves are fixed so they cover the box at any size. For curves you can count, use Paths, whose count sets how many.

API Reference

Beams

<div> data-slot="beams"

PropType
colors?string[]

The beams' gradient, up to three CSS colours: start, middle and end. With two, the middle takes the end's colour; with one, the beams are a single colour. By default cyan, violet and pink.

speed?number

How fast the beams sweep, as a multiplier: each beam takes 4 to 7.2 seconds at 1, half as long at 2.

Default
1
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--beams-color-1string

The gradient's start (cyan).

--beams-color-2string

The gradient's middle (violet).

--beams-color-3string

The gradient's end (pink).

--beams-speedstring

The sweep's speed, a multiplier (1).

All 100 backgrounds