Grid Press Background

A drifting grid of outlined boxes on canvas where random cells glow and the whole grid presses inward like cloth under the cursor, then springs back. Wrap your content in it or drop it behind any section. Fully self-contained: one component, one canvas, no configuration files.

Pressable grid

Push the grid. It springs back.

Move your cursor and the grid presses inward like cloth under a finger. Random cells glow as it drifts — all drawn on one canvas, with zero React re-renders while it animates.

Hover to pressClick to boostCanvas 2D

Installation

  1. 1

    Install the component:

    npx shadcn@latest add https://ui.amines.fun/registry/grid-press-background.json
  2. 2

    Usage:

    jsx

    app/page.jsx

    import GridPressBackground from "@/components/ui/grid-press-background";// Wrap your content — the grid fills the wrapper automatically<GridPressBackground className="flex min-h-screen flex-col justify-center">  <h1 className="text-4xl font-bold text-white">Your content</h1></GridPressBackground>// Or drop it behind an existing section as a pure layer<section className="relative isolate min-h-screen overflow-hidden bg-neutral-950">  <GridPressBackground className="absolute inset-0" fadeEdges />  <div className="relative z-10">...content...</div></section>

Props

PropTypeDefaultDescriptionRequired
childrenReactNode-Optional content rendered inside the wrapper, above the canvas grid.No
classNamestring""Tailwind classes for the wrapper — give it a size like "min-h-screen" or "h-[640px]". When used as a layer, pass "absolute inset-0".No
styleReact.CSSProperties-Inline styles for the wrapper, merged over backgroundColor.No
cellSizenumber44Size of one grid box in pixels. Smaller values mean a denser grid and more boxes to draw.No
gapnumber3Space between boxes in pixels.No
fadeEdgesbooleanfalseFade the grid out toward the edges with a radial mask.No
backgroundColorstring"#09090b"Wrapper background color — any CSS color.No
lineColorstring"#ffffff"Color of the box outlines.No
lineOpacitynumber0.07Opacity of the box outlines, 0 to 1.No
pressColorstring"#6366f1"Fill color of boxes under the cursor as it presses the grid.No
pressOpacitynumber0.45Maximum opacity of the press fill, 0 to 1.No
flashColorstring"#818cf8"Color of the random glowing cells that appear across the grid.No
flashOpacitynumber0.35Maximum opacity of the random glowing cells, 0 to 1.No
driftXnumber10Horizontal drift speed in px/s. Negative values drift left; 0 freezes the grid horizontally.No
driftYnumber6Vertical drift speed in px/s. Negative values drift up; 0 freezes the grid vertically.No
wavenumber2.5Amplitude of the idle wobble in px. Set to 0 to disable it.No
flashesnumber12Maximum number of random glowing cells at once. Set to 0 to disable them.No
interactivebooleantrueMaster switch for the hover/press interaction. Set false for a purely ambient drifting grid.No
radiusnumber200How far around the cursor the grid presses inward, in px.No
depthnumber0.45How deep the grid sinks under the cursor, roughly 0 to 1.No
bouncenumber0.5Spring wobble when the press releases. 0 is a clean settle, 1 is maximum jelly.No
clickBoostnumber1.35Extra press depth while the mouse/touch button is held. Set to 1 to disable.No
trackWindowbooleantruetrue: reacts to the cursor anywhere on the page, even over your content. false: only reacts when the cursor is over the wrapper itself.No
maxFpsnumber60Frame rate cap. Lower values are easier on battery and weak GPUs.No
maxDprnumber2Maximum device pixel ratio the canvas renders at. Lower values are cheaper.No