Join our Discord Community

React Interactive Grid Pattern

Grid backgrounds that light up on hover like Tron. Build responsive React grids with smooth hover effects, TypeScript support, and 60fps performance for Next.js dashboards with shadcn/ui integration.

Powered by

Trying to implement interactive grids?

Join our Discord community for help from other developers.


Static grids are boring. CSS-only grids can't track state. You need a grid that responds to users without killing performance. This React component creates an SVG grid where each cell lights up on hover, running at 60fps even with thousands of cells.

Interactive hover effects

Watch grid cells illuminate as you move your cursor:

Loading component...

Built for React and Next.js with full TypeScript support. The grid uses a single SVG element with minimal DOM manipulation, so hover effects stay smooth even on lower-end devices. Works perfectly with shadcn/ui design systems.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/interactive-grid-pattern.json
npx shadcn@latest add https://www.shadcn.io/registry/interactive-grid-pattern.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/interactive-grid-pattern.json
bunx shadcn@latest add https://www.shadcn.io/registry/interactive-grid-pattern.json

Usage

import { InteractiveGridPattern } from "@/components/ui/interactive-grid-pattern";

export default function Dashboard() {
  return (
    <div className="relative h-screen">
      <InteractiveGridPattern 
        className="absolute inset-0"
        squares={[20, 20]}
      />
      <div className="relative z-10">
        {/* Your content */}
      </div>
    </div>
  );
}

Why most interactive grids suck

Most developers create a div for each cell. Bad move. 400 cells = 400 DOM nodes = sluggish interactions. Others use canvas, which means managing a whole rendering context for what should be a simple hover effect.

This React component uses a single SVG with rect elements. Hover state is tracked with React's useState, but only for active cells. CSS transitions handle the visual changes. Result? Butter-smooth interactions even with 1000+ cells.

Examples

Colorful Hover Effects

Grid with vibrant colors that match your brand:

Loading component...

Multiple Variants

Different grid styles for various use cases:

Loading component...

Features

  • Single SVG rendering for thousands of cells without performance penalty
  • React state tracking only for hovered cells
  • CSS transition animations running at 60fps
  • TypeScript definitions for proper IDE support in React projects
  • Customizable grid density with width/height props
  • Responsive scaling that adapts to container size
  • Radial gradient masking for spotlight effects
  • shadcn/ui compatible using Tailwind CSS classes

API Reference

InteractiveGridPattern

Main grid component that handles hover interactions.

PropTypeDefaultDescription
classNamestring-Additional Tailwind CSS classes for SVG
widthnumber40Width of each grid cell in pixels
heightnumber40Height of each grid cell in pixels
squares[number, number][24, 24]Grid dimensions [columns, rows]
squaresClassNamestring-Classes for interactive square elements

Common gotchas

Too many cells: More than 50x50 grid starts impacting performance. Keep it reasonable—users can't distinguish individual cells beyond that anyway.

Z-index layering: Content needs relative z-10 to appear above the grid. The SVG uses absolute positioning.

Mobile performance: Touch devices don't have hover, so the effect is lost. Consider disabling on mobile or using touch events instead.

Color contrast: Light hover effects get lost on light backgrounds. Use sufficient opacity or color contrast for visibility.

Container sizing: The grid fills its container. Make sure the parent has explicit dimensions or the grid won't render.

Integration with other components

Perfect under Particles for layered effects. Combines well with Gradient for depth. The grid is subtle enough to work behind any shadcn/ui component without competing for attention.

Questions developers actually ask