Background
Grid Pattern
SVG-based grid patterns with masking and highlight effects. Perfect for React applications requiring structured backgrounds with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/grid-pattern.json
npx shadcn@latest add https://www.shadcn.io/registry/grid-pattern.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/grid-pattern.json
bunx shadcn@latest add https://www.shadcn.io/registry/grid-pattern.json
Features
- SVG-based rendering providing crisp, scalable patterns at any resolution
- Customizable grid parameters including cell size, spacing, and positioning offsets
- Advanced mask support enabling gradient overlays and complex visual effects
- Highlighted square system allowing specific grid cells to be styled differently
- Flexible stroke patterns supporting dashed, dotted, and custom stroke configurations
- Performance optimized using efficient SVG pattern definitions for minimal DOM impact
- TypeScript support with complete interface definitions for reliable integration
- Tailwind CSS compatibility enabling easy styling with utility classes and color control
Examples
Linear Gradient Mask
Dashed Pattern
Multiple Variants
Use Cases
This free open source React component works well for:
- Dashboard layouts - Structured grid backgrounds for data visualization interfaces built with Next.js
- Portfolio sections - Professional grid patterns that organize content using TypeScript
- Documentation sites - Technical precision patterns for developer resources and guides
- Landing page backgrounds - Subtle structured patterns that don't compete with content using shadcn/ui
- App interfaces - Grid-based layouts that reinforce information hierarchy
- Presentation templates - Professional patterns for slides and marketing materials using Tailwind CSS
API Reference
GridPattern Props
Prop | Type | Default | Description |
---|---|---|---|
width | number | 40 | Width of each grid cell in pixels |
height | number | 40 | Height of each grid cell in pixels |
x | number | -1 | X offset for the pattern |
y | number | -1 | Y offset for the pattern |
squares | Array<[number, number]> | - | Array of [x, y] coordinates for highlighted squares |
strokeDasharray | string | "0" | SVG stroke-dasharray for dashed patterns |
className | string | - | Additional CSS classes for the SVG element |
Implementation Notes
- Component uses SVG pattern definitions for efficient rendering with minimal DOM impact
- Grid opacity and color controlled via Tailwind
fill-
andstroke-
utility classes - Mask effects supported using CSS mask properties for gradient overlays and spotlight effects
- Highlighted squares created by providing array of [x, y] coordinates in
squares
prop - Stroke patterns customizable via
strokeDasharray
for dashed, dotted, or custom line effects - Positioning adjustable through
x
andy
offset parameters and CSS transform classes - Compatible with shadcn/ui design system and responsive across all device sizes
- Use
[mask-image:radial-gradient()]
for spotlight effects or[mask-image:linear-gradient()]
for directional fades
Flickering Grid
Canvas-based flickering grid animations with performance optimization. Perfect for React applications requiring subtle animated backgrounds with Next.js integration and TypeScript support.
Hexagon Background
Responsive hexagon grid background with hover effects and customizable sizing. Perfect for React applications requiring geometric patterns with Next.js integration and TypeScript support.