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

Loading component...

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

Loading component...

Dashed Pattern

Loading component...

Multiple Variants

Loading component...

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

PropTypeDefaultDescription
widthnumber40Width of each grid cell in pixels
heightnumber40Height of each grid cell in pixels
xnumber-1X offset for the pattern
ynumber-1Y offset for the pattern
squaresArray<[number, number]>-Array of [x, y] coordinates for highlighted squares
strokeDasharraystring"0"SVG stroke-dasharray for dashed patterns
classNamestring-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- and stroke- 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 and y 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