shadcn.io is an independent project built on shadcn/ui
Beams Background for Vue
Beams of light run along a fanned sheaf of fine curved paths. For Vue with Ark UI, when a hero needs motion that stays behind the copy.
On this page10 sections
A sheaf of fine curved paths sweeps across the box and fans out, and beams of light run along them: a bright head, a small halo and a tail that fades through a palette you choose. A second, softer sheaf sits behind for depth. It's a GLSL scene on WebGL2 with no dependency. The scene is transparent and reads the surface behind it, so the beams glow on a dark page and turn to colored ink on a light one, and the paths near the pointer light up.
Use it behind a hero, a feature section or a card. For beams that fall and burst on a floor, use Beams Collision; for a bundle of single-color curves that draw themselves, Paths; for streaks that rush out of a vanishing point, Warp. With reduced motion it holds one still frame.


Installation
Usage
<script setup lang="ts">
import { Beams } from "@/components/ui/beams";
</script>
<template>
<Beams class="flex min-h-[32rem] flex-col items-center justify-center">
<h1 class="text-5xl font-semibold">Every change, on every screen</h1>
</Beams>
</template>
Beams is a container: whatever you put inside sits on top of the paths, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".
Presets
<Beams /><Beams
:count="8"
:frequency="1.4"
:glow="2"
:length="0.7"
:tracks="0.3"
:width="3"
/><Beams
:colors="['#a7f3d0', '#34d399', '#0ea5e9']"
:count="48"
:curve="0.6"
:frequency="1.5"
:length="0.22"
:width="0.75"
/><Beams
:angle="90"
:colors="['#fdba74', '#f97316', '#e11d48']"
:curve="0.3"
:fan="1"
/><Beams
:angle="0"
:colors="['#fda4af', '#f43f5e', '#7c3aed']"
:count="16"
:curve="0"
:fan="1"
:length="0.6"
:width="1.5"
/><Beams
:colors="['var(--foreground)', 'var(--muted-foreground)']"
:glow="0.3"
:tracks="0.9"
/><Beams :angle="-32" :count="40" :curve="0.4" :fan="0" :spread="0.6" />Each preset is a set of props, so copy one and keep tuning. Sheaf is the default. Parallel runs the paths side by side as one tight band, Fountain turns them upward from a point at the bottom edge, Fiber packs 48 hairlines with short pulses, and Mono takes its colors from your theme.
Examples
Hero
The paths are 1.25 pixels wide and the beams are sparse, so the copy sits in the middle of the box, right over them. The headline and the line under it use the foreground color; the chip and the second button have a translucent ground of their own.
Fountain
angle={90} sends the beams upward and fan={1} gathers the paths into a point at the bottom edge, so they open like a fountain. colors runs from a beam's head to the end of its tail: here peach, orange and crimson on a dark surface.
In a card
fan={0} keeps the 40 paths side by side and spread={0.6} narrows them into a band that crosses the card at angle={-32}. The colors are the theme's foreground and muted foreground, and fade="bottom" clears the lower half for the copy.
Customization
Every color is a CSS color, so a theme variable works and follows a theme switch: colors={["var(--chart-1)", "var(--chart-2)"]}. The palette runs from head to tail and is mixed in OKLab, so two distant hues meet in a clean color, not a grey one. The fixed paths take a tint of the palette's middle; tracks sets how strongly they show, and 0 hides them.
The surface is the root's own background, bg-background by default. Give the root another (bg-slate-950, an image, a gradient) and the beams adapt: they add light to a dark surface and draw in deeper ink on a light one. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.
<Beams
angle={-32}
className="min-h-[32rem] bg-slate-950"
colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]}
fade="bottom"
fan={0}
spread={0.6}
/>Performance
It's one WebGL2 canvas and one fragment shader with no noise in it. For each pixel it finds the five nearest paths in each of the two sheaves and works out a distance and a few sines for each, so the cost doesn't grow with count. It draws only while it's on screen and the tab is visible, shares one frame loop with every other background on the page, and lowers its own resolution if frames run long. quality sets the render scale yourself, and paused holds the frame.
Accessibility
The beams are decoration: they're hidden from assistive tech and let every click through to your content. With reduced motion it draws one still frame and ignores the pointer. Nothing flashes: a beam takes 5 to 12 seconds to cross the box.
Put copy over it in the foreground color (text-foreground). The paths are hairlines and the surface between them is untouched: measured on the default look, 99% of the pixels keep foreground text above 7.9:1 on a dark surface and above 11:1 on a light one, and no 24-pixel block averages below 7:1. The one weak spot is the head of a beam on a dark surface, a dot about 3 pixels wide that is nearly as light as white text and moves on within a second. Lower intensity or glow if body copy sits on many paths.
FAQ
How do I change the colors?
Pass two to eight CSS colors to colors. The first is the head of each beam and the last is the end of its tail, with the rest spread between. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes. The fixed paths take a tint of the same palette.
Does it work on a light page?
Yes, with no prop to set. The scene reads the color behind it: on a dark surface the beams add light, and on a light one they draw as ink in the same hues, deeper, and pale colors most, so a cyan or peach head still shows on white. Set the surface with a class on the component, such as bg-slate-950.
How do I change the direction of the beams?
angle is the direction of travel in degrees: 0 runs left to right, 90 upward, -90 downward, 180 right to left. curve={0} makes the paths straight, and fan decides whether they run side by side (0) or leave one point and open out (1). The sheaf always stretches to fill the box, whatever its shape.
How do I show more or fewer beams?
count is the number of paths, from 6 to 48, and frequency is how often a beam runs down each one. At the defaults about half of the 30 paths carry a beam at any moment. frequency={2} lights every path all the time, and frequency={0.2} leaves one or two beams on screen. tracks={0} hides the paths and keeps the beams.
How do I put it behind the whole page?
Render it empty with className="fixed inset-0 -z-10". It still follows the pointer there, since it listens on the window. To put it behind one section, wrap that section's content in it and give it a height, such as min-h-svh.
Will it slow my page down?
It's a light shader: ten distance checks a pixel and no noise, on the GPU, and nothing at all while it's off screen or the tab is hidden. If a device can't keep up, it renders fewer pixels by itself. Thin lines show a lower resolution sooner than soft gradients do, so keep quality at 0.75 or above.
Does it work with Next.js and server components?
Yes. Import it into a server component and it renders its box and your content on the server; the canvas starts in the browser and fades in over the surface. It needs WebGL2, which every current browser has. Without it the box keeps its background, or the fallback you pass.
API Reference
Beams
data-slot="beams"
angle?number
The direction the beams travel, in degrees from -180 to 180: 0 runs left to right, 90 runs upward, -90 runs downward.
- Default
28
colors?string[]
Two to eight CSS colors, from a beam's head to the end of its tail.
Theme variables such as var(--primary) follow your theme.
- Default
["#67e8f9", "#6d5cff", "#d946ef"]
count?number
How many paths the sheaf has, from 6 to 48.
- Default
30
curve?number
How much the paths bend on their way across, from 0 (straight lines) to 2.
- Default
1
fade?"none" | "radial" | "top" | "bottom" | "left" | "right"
Which edges fade out to the surface: radial keeps the middle, the
others name the side that fades.
- Type
"none" | "radial" | "top" | "bottom" | "left" | "right"- Default
"none"
fallback?string
What shows until the first frame and in browsers without WebGL2: a CSS
background value that looks like the scene.
fan?number
How much the sheaf opens along the way, from 0 (the paths run side by side) to 1 (a tight bundle that fans out).
- Default
0.7
frequency?number
How often a beam runs down each path, from 0.2 to 2: higher lights more paths at once.
- Default
1
glow?number
The halo around each beam and its head, from 0 to 2.
- Default
1
grain?number
Film grain over the scene, from 0 to 1.
- Default
0
intensity?number
How bright the beams are, from 0 to 2. The fixed paths keep their own
strength (tracks).
- Default
1
interactive?boolean
Whether the scene follows the pointer and answers a press. Touch never moves it, so scrolling a page on a phone isn't disturbed.
- Default
true
length?number
How long a beam's tail is, as a share of the box, from 0.05 to 1.
- Default
0.4
opacity?number
How strongly the scene shows over the surface, from 0 to 1.
- Default
1
paused?boolean
Holds the current frame.
- Default
false
quality?number
Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). Lower is cheaper and softer.
- Default
1
seed?number
Another layout of the same look, from 0 to 20: which paths are lit, and when.
- Default
0
speed?number
Animation speed: 1 is normal, 0 holds the frame.
- Default
1
spread?number
How wide the sheaf is across the box, from 0.2 to 2.
- Default
0.9
time?number
A fixed moment, in seconds: draws it and doesn't animate.
tracks?number
How strongly the fixed paths show under the beams, from 0 to 1.
- Default
0.6
width?number
The thickness of a beam and of its path, in pixels, from 0.5 to 4.
- Default
1.25











