Grid

Responsive grid layout for arranging items in columns with consistent spacing

Setup

import { Grid } from '@fragments-sdk/ui';

Examples

Default

Basic 3-column grid

Loading preview...

Responsive

1 column on mobile, 2 on tablet, 3 on desktop

Loading preview...

Auto-fill

Responsive grid that auto-fills based on minimum child width

Loading preview...

Numeric Gap

Using number values (1-8) mapped to the spacing scale

Loading preview...

With Spanning

Grid items spanning multiple columns

Loading preview...

Form Layout

Two-column form that collapses to single column on mobile

Loading preview...

Props

PropTypeDefaultDescription
childrennodeNot setGrid items and content
columnsunion1Number of columns: a number (1-12), a responsive object { base, sm, md, lg, xl }, or "auto" for auto-fill
minChildWidthstringNot setMinimum width for auto-fill columns (e.g., "16rem", "250px")
gapunionnonexssmmdlgxlmdGap between grid items. Accepts string tokens or numbers (1-8) mapped to the spacing scale
alignItemsenumstartcenterendstretchNot setVertical alignment of items within their cells
justifyItemsenumstartcenterendstretchNot setHorizontal alignment of items within their cells
paddingenumnonesmmdlgnoneInternal padding of the grid container
classNamestringNot setAdditional class name
styleobjectNot setInline styles

Usage Guidelines

When to use

  • Arranging cards, tiles, or media in a responsive grid
  • Building form layouts with multi-column fields
  • Creating dashboard layouts with widgets
  • Any content that should reflow across breakpoints

When not to use

  • Single-column stacked content (use a simple flex column or Stack)
  • Navigation bars or toolbars (use a dedicated nav component)
  • Content that must not wrap (use inline layout)

Best practices

  • Use columns="auto" with minChildWidth for grids that adapt without breakpoints
  • Use responsive object { base: 1, md: 2, lg: 3 } when you need explicit control per breakpoint
  • Use fixed column counts when exact column control is needed and responsiveness is not required
  • Use Grid.Item with colSpan to create asymmetric layouts within a fixed grid
  • Keep gap consistent within a context — md is the default and works for most cases
  • Pass DOM attributes (id, role, aria-*, data-*, event handlers) directly to Grid and Grid.Item roots when needed
Accessibility
  • Grid is purely visual — it does not affect reading order or semantics
  • Ensure logical source order matches visual order for screen readers