shadcn.io is an independent project built on shadcn/ui
Interactive Grid Pattern Background for Solid
A line grid whose cells fill under the pointer and fade behind it as a trail. For Solid with Ark UI, when a hero should answer the pointer.
On this page10 sections
A grid of thin lines where the cell under the pointer fills, the cells around it fill a little, and each one fades out behind the pointer as a trail. A press sends a ring outward through the cells, the lines brighten around the pointer, and a few cells light and fade on their own, so the grid is alive on a touch screen too. It's a GLSL scene on WebGL2: a small simulation holds the trail, and the lines are snapped to the screen's pixels, so a 1 px line is one crisp pixel at any size. It follows your theme on light and dark.
Use it behind a hero, a dashboard or a sign-in page that should answer the pointer. For the same grid in plain CSS with no pointer, use Grid Pattern; for cells that blink on their own, Flickering Grid; for tiles that lift in perspective, Boxes. With reduced motion it holds one frame and ignores the pointer.


Installation
Usage
import {
InteractiveGridPattern,
} from "@/components/ui/interactive-grid-pattern";<InteractiveGridPattern
class="flex min-h-[32rem] flex-col items-center justify-center"
fade="radial"
>
<h1 class="text-5xl font-semibold">Every block snaps into place</h1>
</InteractiveGridPattern>Interactive Grid Pattern is a container: whatever you put inside sits on top of the grid, 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"; cells still light under the pointer there.
Presets
<InteractiveGridPattern /><InteractiveGridPattern
color="#3b82f6"
fillColor="#3b82f6"
intensity={1.5}
size={32}
/><InteractiveGridPattern fade="radial" size={32} variant="crosses" /><InteractiveGridPattern
lineWidth={1.5}
radius={120}
size={24}
variant="dots"
/><InteractiveGridPattern
fillColor="#f97316"
intensity={1.8}
radius={140}
trail={0.9}
/><InteractiveGridPattern
activity={0.7}
lineWidth={0.5}
radius={60}
size={16}
/><InteractiveGridPattern
activity={0.9}
fillColor="#6366f1"
inset={3}
intensity={1.6}
size={48}
trail={0.7}
/>Each preset is a set of props, so copy one and keep tuning. Grid is the default, in your theme's own greys. Crosses and Dots draw only the corners of the cells, for a lighter page. Tiles floats a rounded indigo tile inside each lit cell, and Fine is a 16 px grid with half-pixel lines.
Examples
Hero
fade="radial" lets the grid thin out toward the edges of the box. intensity={1.5} draws it a little stronger under the headline, and activity={0.8} lights more cells on their own.
Tiles
inset={3} leaves 3 px between a lit cell's fill and its lines and rounds its corners, so the fills read as tiles. They take fillColor="#6366f1", and trail={0.7} keeps them lit longer behind the pointer.
In a card
A 24 px grid in a card, with fade="bottom" thinning it out where the copy sits.
Customization
color draws the grid and fillColor fills the lit cells. Both take any CSS color and follow a theme switch; the defaults are var(--foreground) and var(--muted-foreground), drawn faintly, so the grid is grey on any theme. size and lineWidth are CSS pixels, and variant draws whole lines, a cross at each corner, or a dot.
The surface is the root's own background, bg-background by default: give the root another and the grid sits on it. On a fixed dark surface in a light theme, pass your own light colors, since the theme's tokens stay dark there. radius and trail set how wide and how long the pointer lights cells, ripple the ring of a press, activity the cells that light by themselves, and fade, grain and opacity fit it into a layout.
<InteractiveGridPattern
class="min-h-[32rem]"
color="var(--primary)"
fade="radial"
fillColor="var(--chart-1)"
intensity={1.5}
size={32}
/>Performance
It's one WebGL2 canvas with no dependency. The trail is a texture a quarter of the box's size in CSS pixels (360 by 225 for a 1440 by 900 box), and a run reads two of its texels a texel. The scene reads one texel a pixel, with one hash and no noise. 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 grid is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one frame, with a few cells lit, and ignores the pointer and presses. Cells take two to five seconds to light and fade on their own, and the ring of a press passes each cell once, so nothing flashes.
The default grid is drawn at 14% of its color and a fully lit cell at 30%, in grey: at rest the worst pixel measured 10.6:1 under dark text and 7.6:1 under light text, and 5.8:1 on the lines brightened around the pointer. With a bright fillColor and a high intensity on a dark surface, check the copy that sits on lit cells.
FAQ
How do I change the colors?
Set color for the grid and fillColor for the lit cells. Both take any CSS color: hex, oklch() or a theme variable such as var(--chart-1), which follows your theme when it changes. The grid is drawn at 14% and a lit cell at 30% of the color; intensity scales both, up to twice that.
How do I make the trail longer or shorter?
trail runs from 0 to 1: at 0 a cell goes dark about 0.15 s after the pointer leaves it, at the default 0.5 in a little under a second, and at 1 in about 3 s. radius sets how far around the pointer cells light: 0 lights only the cell under it.
What happens on phones and touch screens?
Touch never lights cells, so scrolling the page isn't disturbed. The grid stays alive anyway: a share of the cells, set by activity, light and fade on their own every 7 to 16 seconds. Set activity={0} for a grid that only answers the pointer.
Are the lines sharp on every screen?
Yes. Each line starts on a whole device pixel and is lineWidth CSS pixels wide, so a 1 px line is exactly one pixel on a standard screen and two on a 2x one, with no blur. A width that isn't a whole number of device pixels, such as 0.5 on a standard screen, is drawn lighter.
How do I put it behind the whole page?
Render it empty with className="fixed inset-0 -z-10". It listens for the pointer on the window, so cells light under the pointer even with content on top, and presses on links, buttons and fields don't start a ring.
Can I turn off the ring on a press, or the pointer altogether?
ripple={0} turns the ring off and keeps the trail. interactive={false} turns off everything the pointer does, and leaves the cells that light on their own. spotlight={0} stops the lines from brightening around the pointer.
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.
When should I use the CSS Grid Pattern instead?
When the grid doesn't need to answer the pointer. Grid Pattern is a CSS background with no canvas and no script, and it has dashes, heavier lines every few cells and highlighted squares. This one is for the trail, the ring and the cells that light by themselves.
API Reference
InteractiveGridPattern
data-slot="interactive-grid-pattern"
activity?number
How many cells light and fade on their own, from 0 (none) to 1.
- Default
0.5
color?string
The CSS color of the grid. The default follows your theme.
- Default
"var(--foreground)"
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.
fillColor?string
The CSS color a lit cell fills with. The default follows your theme.
- Default
"var(--muted-foreground)"
grain?number
Film grain over the scene, from 0 to 1.
- Default
0
inset?number
The space between a lit cell's fill and its lines, in pixels: 0 fills the cell, more floats a rounded tile inside it.
- Default
0
intensity?number
How strong the grid and the lit cells are, from 0 to 2.
- 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
lineWidth?number
The width of a line, in pixels.
- Default
1
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
radius?number
How far around the pointer cells light, in pixels.
- Default
90
ripple?number
How strong the ring a press sends through the cells is, from 0 to 2.
- Default
1
seed?number
Another choice of the cells that light on their own, from 0 to 20.
- Default
0
size?number
The size of a cell, in pixels, from 12 to 96.
- Default
40
speed?number
Animation speed: 1 is normal, 0 holds the frame.
- Default
1
spotlight?number
How much the lines brighten around the pointer, from 0 to 1.
- Default
0.6
time?number
A fixed moment, in seconds: draws it and doesn't animate.
trail?number
How long a cell stays lit behind the pointer, from 0 to 1.
- Default
0.5
variant?"lines" | "crosses" | "dots"
How the grid is drawn: whole lines, a cross at every corner, or a dot.
- Type
"lines" | "crosses" | "dots"- Default
"lines"











