Grid and columns
Layouts that decide on the width of their container, not the viewport — compact, regular or expanded — like the native ones: a grid of equal cells that never gets narrower than minItemWidth, and weighted columns that sit side by side or stack. Pure CSS (@container), safe with right-to-left and with text at 200 %.
- Domain
- Navigation & shell
- Support level
- Size
- 1.7 kB gzip, budget 1.3 kB
- Who uses it
- No live product imports it yet Counted in the dated inventory of 2026-11-23.
import { Grid, Columns } from "@krizaka/ui/columns";Web only — React, from @krizaka/ui/columns. Beta: its API may still change in a minor version.
- Mobile · n/a. React Native has its own Grid and Columns with the same props: they measure the room with
onLayout. → Grid and columns
Why it is here. The UI Builder's Columns block and any block that must follow the width of its container, in a page, a side sheet or a canvas.
When to use
- A block of cards, photos or stats that is one column in a narrow panel, two in a regular one and three or more in a wide one — wherever it is placed, in a page, a side sheet or a builder canvas.
- A form and its summary, a master and its detail: weighted columns that stack when their container is too narrow.
- A page the user zooms or whose text they enlarge: the room an item needs grows with the text, so nothing overflows.
When not to use
- A grid of cards with a staggered reveal on a site's page.Use instead: Card grid
- A table of data that sorts, filters and pages.Use instead: Data table
- A page frame with a header, a body and a side.Use instead: Detail layout
Installation
Install
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Import
import { Grid, Columns } from "@krizaka/ui/columns";Examples
Photos
Two columns in a compact container, three in a regular one, four in an expanded one; tiles never narrower than 120 px.
A stat strip
Cards of equal height: two per row in a narrow container, four in a wide one, one at 200 % text.
Columns
A third and two thirds that stack when the container cannot hold them.
Props
Columns
A few columns that sit side by side when their container holds them and stack when it does not — the master and the detail, a form and its summary. Stacked, they keep their order and each takes the full width.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | ReactNode | — | The columns, in reading order (the first is at the start edge, on the right in right-to-left). |
fontScale | number | 1 | The text scale to lay out for, on top of the browser's. Pass 2 to see 200 % text. |
gap | "sm" | "lg" | "none" | "md" | "xs" | "xl" | lg | The space between columns, and between stacked ones (default lg). |
minColumnWidth | number | 280 | Below this width per column, in px, the columns stack top to bottom (default 280); it grows with the text scale. |
weights | readonly number[] | — | The share of each column (default equal); [1, 2] is a third and two thirds. |
Grid
A grid that fits its container: the columns come from the size class of the container's width, and no cell is narrower
than minItemWidth, so nothing overflows in a page, a side panel or a split. The order mirrors in right-to-left.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | ReactNode | — | The items. Each is one cell. |
columns | GridColumns | — | Columns per size class of the container the grid is in (default 1 · 2 · 3), or one number. A ceiling: it drops when minItemWidth does not fit. |
equalHeight | boolean | true | The cells of a row are as tall as the tallest (default true); false lets each keep its own height. |
fontScale | number | 1 | The text scale to lay out for, on top of the browser's (widths are in rem, so a larger text size is followed already). Pass 2 to see 200 % text. |
gap | "sm" | "lg" | "none" | "md" | "xs" | "xl" | md | The space between cells (default md). |
maxColumns | number | 6 | The most columns, whatever the container (default 6). |
minItemWidth | number | 160 | No cell is narrower than this, in px (default 160); it grows with the text scale. |
Accessibility
- A grid with an
aria-labelis a list and its cells are list items, so a screen reader announcesPhotos, list, 8 items. - The reading order is the order of the children in every size class; columns only change where they sit.
- Widths are in
rem: at 200 % text no cell is narrower than twiceminItemWidth, so the text wraps in a wide cell instead of being cut.
Best practices
- Ask for columns by size class of the container:
{ compact: 1, regular: 2, expanded: 3 }is the default; a gallery says{ compact: 2, regular: 3, expanded: 4 }. The numbers are a ceiling. - Set
minItemWidthto what the item needs to be readable (a stat card 140, a photo 100): the grid drops columns before an item gets narrower. Columnsstacks belowminColumnWidth(280 by default) per column; weights[1, 2]give a third and two thirds side by side.- Use the gap tokens (
xs4,sm8,md12,lg16,xl24), never a number: they are the same as native. - The grid is an inline-size container: give it a width from its parent (a block is enough), not a shrink-to-fit one.
- Right-to-left needs nothing: no physical edge is used, the first item is at the start edge.
Related components
Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub