[1, 3] or [1, "auto", 1]. Children fill cells left-to-right, wrapping to new rows.
Basic Usage
Columns
The same set of children reflows as the column count changes.- columns=2
- columns=3
- columns=4
Custom Column Widths
Pass a list tocolumns for unequal-width columns. Integers become fractional units (1 → 1fr, 2 → 2fr) and strings pass through as CSS values ("auto", "200px").
The "auto" keyword sizes a column to its content, which works well for separators or fixed-width controls between fluid areas.
Spanning Cells
Wrap a child inGridItem to make it span multiple columns or rows. Children without a GridItem wrapper take a single cell. The grid still auto-flows, so items reflow responsively as columns change.
row_span works the same way for vertical spanning. This is useful for tall cards alongside shorter ones in dashboard-style layouts.
Auto-fill Columns
Setmin_column_width instead of columns to let CSS Grid automatically fit as many columns as possible, each at least the given width. Drag the handle to see the grid reflow.
Responsive Columns
Pass a dictionary of breakpoints tocolumns for precise control at specific viewport widths. The default key sets the base, and Tailwind breakpoints (sm, md, lg, xl, 2xl) override it progressively.
gap, css_class, and the Responsive helper.
Nested Content
Grids nest naturally with other containers:API Reference
Grid Parameters
Number of grid columns (1-12), or a list of column widths. Can be passed as a positional argument. In a list, integers become fractional units (
1 → 1fr) and strings pass through ("auto", "200px"). Pass a dict or Responsive() for breakpoint-aware column counts. Mutually exclusive with min_column_width.Minimum column width for auto-fill responsive grids (e.g.
"16rem"). CSS Grid fits as many columns as possible at this minimum width. Mutually exclusive with columns.Gap between children. An int maps to
gap-{n}. A tuple (x, y) sets per-axis gaps; use None to skip an axis. A Responsive() sets different gaps at different breakpoints.Cross-axis alignment:
"start", "center", "end", "stretch", "baseline".Main-axis distribution:
"start", "center", "end", "between", "around", "evenly", "stretch".Additional Tailwind CSS classes. A
Responsive() compiles breakpoint-prefixed classes.Protocol Reference
Grid