BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/magicui/interactive-grid-pattern

Interactive Grid Pattern

magicui/interactive-grid-pattern
FreeComponent

A interactive background grid pattern made with SVGs, fully customizable using Tailwind CSS.

Live preview

live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://magicui.design/r/interactive-grid-pattern.json

Source

registry/magicui/interactive-grid-pattern.tsxmagicui.design/r/interactive-grid-pattern.json
1"use client"
2
3import React, { useState } from "react"
4
5import { cn } from "@/lib/utils"
6
7/**
8 * InteractiveGridPattern is a component that renders a grid pattern with interactive squares.
9 *
10 * @param width - The width of each square.
11 * @param height - The height of each square.
12 * @param squares - The number of squares in the grid. The first element is the number of horizontal squares, and the second element is the number of vertical squares.
13 * @param className - The class name of the grid.
14 * @param squaresClassName - The class name of the squares.
15 */
16interface InteractiveGridPatternProps extends React.SVGProps<SVGSVGElement> {
17 width?: number
18 height?: number
19 squares?: [number, number] // [horizontal, vertical]
20 className?: string
21 squaresClassName?: string
22}
23
24/**
25 * The InteractiveGridPattern component.
26 *
27 * @see InteractiveGridPatternProps for the props interface.
28 * @returns A React component.
29 */
30export function InteractiveGridPattern({
31 width = 40,
32 height = 40,
33 squares = [24, 24],
34 className,
35 squaresClassName,
36 ...props
37}: InteractiveGridPatternProps) {
38 const [horizontal, vertical] = squares
39 const [hoveredSquare, setHoveredSquare] = useState<number | null>(null)
40
41 return (
42 <svg
43 width={width * horizontal}
44 height={height * vertical}
45 className={cn(
46 "absolute inset-0 h-full w-full border border-gray-400/30",
47 className
48 )}
49 {...props}
50 >
51 {Array.from({ length: horizontal * vertical }).map((_, index) => {
52 const x = (index % horizontal) * width
53 const y = Math.floor(index / horizontal) * height
54 return (
55 <rect
56 key={index}
57 x={x}
58 y={y}
59 width={width}
60 height={height}
61 className={cn(
62 "stroke-gray-400/30 transition-all duration-100 ease-in-out not-[&:hover]:duration-1000",
63 hoveredSquare === index ? "fill-gray-300/30" : "fill-transparent",
64 squaresClassName
65 )}
66 onMouseEnter={() => setHoveredSquare(index)}
67 onMouseLeave={() => setHoveredSquare(null)}
68 />
69 )
70 })}
71 </svg>
72 )
73}

Files it writes

  • registry/magicui/interactive-grid-pattern.tsx

Facts

Registry
magicui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on magicui magicui.design magicuidesign/magicui on GitHub Raw registry item This item as JSON

More from magicui

All 247 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AndroidandroidmagicuiComponentsFreeno deps
Animated Beamanimated-beammagicuiComponentsFree1 dep
Animated Circular Progress Baranimated-circular-progress-barmagicuiComponentsFreeno deps
Animated Gradient Textanimated-gradient-textmagicuiComponentsFreeno deps
Animated Grid Patternanimated-grid-patternmagicuiComponentsFree1 dep
Animated Listanimated-listmagicuiComponentsFree1 dep
Animated Shiny Textanimated-shiny-textmagicuiComponentsFreeno deps
Theme Toggleranimated-theme-togglermagicuiComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex