Skip to content

Background Boxes

Motion

React background of skewed hairline boxes: the box under the pointer lights up in colour and fades out, driven by one pointer handler and CSS transitions.

src/registry/premium/background-boxes.tsx/r/background-boxes.json

Installation

bash
npx shadcn@latest add @minidev/background-boxes

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/background-boxes.json

Usage

tsx
import { BackgroundBoxes } from "@/components/ui/background-boxes"

export function Example() {
  return (
    <BackgroundBoxes />
  )
}

API reference

BackgroundBoxes props
PropTypeDefault
densityBox density. 1 draws 64px boxes, 2 draws them half the size.number1
colorsColours the boxes light up in. Any CSS colour, including var(--token).string[]["var(--accent)", "var(--accent-2)", ...
fadeSeconds a lit box takes to fade back.number1.6
idleBoxes that light on their own each second while nobody hovers. 0 turns the idle flicker off.number2
skewTilt of the grid in degrees: skew along x, then along y.[number, number][-24, 12]
classNamestring-
childrenReact.ReactNode-

When to use

Use it as an interactive hero backdrop; children render on top. For quiet ambient motion use FlickeringGrid or AuroraBackground instead.

Accessibility

  • The whole grid is aria-hidden and only reacts to the pointer, so keyboard and screen reader users get the content alone.
  • Under reduced motion the idle flicker is off and lit boxes clear instantly (--bb-fade: 0s).

Frequently asked questions

Do buttons and links on top of BackgroundBoxes still work?

Yes. The pointer handler sits on the outer panel and the grid layer is pointer-events-none, so your content gets clicks while the box under the cursor still lights.

Why is the grid missing from the server HTML?

The grid is measured on the client with a ResizeObserver, so the server renders an empty panel and hydration matches. The boxes appear after the first measure.

How many DOM nodes does it create?

One <div> per box. A 1200 by 360 panel at density={1} (64px boxes) makes about 400, and density={2} makes about four times as many. Lower density for very large panels, and pass idle={0} to turn off the random flicker.

Dependencies

npm

lucide-reactmotion

Built from

Examples

Custom content

Children sit above the grid and the pointer still lights boxes through them.

Dense and quick

density 2 halves the box size; a short fade and more idle flickers per second read as a busy board.

Flat, one colour

A zero skew lays the grid flat, one colour keeps it quiet and idle 0 lights boxes only under the pointer.

All Animated React components