Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Laser Grid Background for React

A neon grid with short beams of light racing along its rows and columns, flaring at each crossing they pass. For React with Base UI, when a gaming, AI or infrastructure hero should feel wired into the mainframe.

Framework

A glowing neon grid with short beams of light racing along its rows and columns, lighting each crossing they pass, like a Tron floor seen from above. The lines, their glow, the beams and the flares are CSS gradients moved by keyframes the install adds to your stylesheet, and the beams snap to the lines in a box of any size.

Use it for gaming, AI or infrastructure heroes. For a quieter board with traces and slower signals, use Circuit; for a synthwave grid in perspective, Retro Grid; for the grid without motion, Grid Pattern.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { LaserGrid } from "@/components/ui/laser-grid";

Laser Grid is a container: give it a size and put your content inside. The grid sits behind the content and the box clips it.

<LaserGrid className="flex min-h-[420px] items-center justify-center">
  <h1 className="text-5xl font-semibold">Every packet, at light speed</h1>
</LaserGrid>

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

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

Demos

Theme colours

By default the grid keeps its signature neon: cyan lines and beams, one beam in five magenta, in light and dark. Pass theme colours to beamColor, accentColor and lineColor to follow your theme instead.

Preview width

Dense

A tighter grid in a dark card: gridSpacing={32}, count={40} beams and speed={1.5}.

Preview width

Accessibility

The grid is decorative: it's hidden from screen readers and lets every click through to your content. With reduced motion the grid stops breathing and the beams stop where they are, mid-line, so the page shows a still picture of the grid. Nothing flashes: the grid breathes over more than three seconds and the flares are small moving highlights, not lights switching on and off. The lines are faint (a quarter of the beams' colour), so headline text in your foreground colour stays readable.

FAQ

How do I change the number of beams?

count sets how many race at once (24). They're spread over the rows and columns of whatever box they're in, so they all stay in view, even in a small card.

Can it use my theme's colours instead of neon?

Yes: pass beamColor="var(--primary)", a paler accentColor and a faint lineColor, as in "Theme colours". You can also set --laser-grid-beam-color, --laser-grid-accent-color and --laser-grid-line-color from your own CSS; the lines follow the beams' colour unless you set them.

How do I make the grid tighter?

gridSpacing sets the distance between lines in pixels (64). The beams snap to the lines at any spacing and in a box of any size.

How do I get the original dark Tron look?

Give the container a near-black background class, such as bg-[oklch(0.13_0.04_265)], and white text. The neon colours are the default.

Does it cost much?

No script runs: the layout is computed when the page renders, the beams move by translate and the grid breathes by opacity, which the browser animates without repainting the page.

What happens with reduced motion?

The grid stops breathing and the beams freeze mid-line, so the page shows a still grid with a few beams on it.

API Reference

LaserGrid

<div> data-slot="laser-grid"

PropType
accentColor?string

The colour of one beam in five, any CSS colour.

Default
a neon magenta
beamColor?string

The beams' colour, any CSS colour. @default a neon cyan.

count?number

How many beams race at once. They're spread over the rows and columns of whatever box they're in, so all of them are always in view.

Default
24
gridSpacing?number

The distance between grid lines, in pixels. @default 64.

lineColor?string

The grid lines' colour, any CSS colour.

Default
the beams' colour at 25%
speed?number

How fast the beams race and the grid breathes, as a multiplier: 0.5 is calm, 2 is frantic.

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
--laser-grid-accent-colorstring

One beam in five (a neon magenta).

--laser-grid-beam-colorstring

The beams' colour (a neon cyan).

--laser-grid-line-colorstring

The grid lines' colour (the beams' at 25%).

--laser-grid-speedstring

How fast it moves, a multiplier (1).

All 100 backgrounds