Skip to main content

Overview

The Grid component provides a powerful and flexible layout system based on CSS Grid. It makes it easy to create responsive, multi-column layouts without manual media queries.

Basic Usage

Column Configuration

Fixed Columns

Responsive Columns

Custom Column Widths

Gap Spacing

Grid Item Spans

Control how many columns/rows individual items span:

Row Spans

Alignment

Horizontal Alignment

Vertical Alignment

Props

Grid Props

number | object
Number of columns or responsive object: { mobile: 1, tablet: 2, desktop: 3 }
number
Number of rows
string
Custom grid-template-columns value (e.g., "1fr 2fr 1fr")
string
default:"md"
Gap between all items: none, sm, md, lg, xl, or custom value
string
Gap between rows (overrides gap for rows)
string
Gap between columns (overrides gap for columns)
string
Horizontal alignment: start, center, end, or stretch
string
Vertical alignment: start, center, end, or stretch
ReactNode
required
Grid items
string
Additional CSS class names

GridItem Props

number
Number of columns this item should span
number
Number of rows this item should span
number
Column line where item starts
number
Column line where item ends
number
Row line where item starts
number
Row line where item ends
ReactNode
required
Item content

TypeScript Interfaces

Layout Examples

Card Grid

Dashboard Layout

Holy Grail Layout

Use responsive column configuration to automatically adapt your layout for different screen sizes without media queries.
For simple column layouts, Grid is often simpler than Flexbox. For single-direction layouts with dynamic sizing, consider using Flexbox instead.

Accessibility

  • Uses semantic HTML structure
  • Maintains logical reading order for screen readers
  • Keyboard navigation works naturally with document flow
  • Consider using order property carefully to avoid disconnecting visual and DOM order