Grid
A CSS grid, the two-axis partner to Stack. Gap is grid.gap (density-aware), and there is no gap prop. Pass one of columns or minItemSize, or neither and set the tracks yourself.
On this page
Server Components can import it from @tounsoo/todae/grid. That entry has no 'use client' and no hooks.
Columns
columns sets a fixed number of equal columns. They stay equal even when an item's content is wider than its share.
import { Card } from '@tounsoo/todae/card';
import { Grid } from '@tounsoo/todae/grid';
const PLANS = ['Free', 'Team', 'Business', 'Enterprise'];
export default function GridColumns() {
return (
<Grid.Root columns={2} role="list" aria-label="Plans">
{PLANS.map((plan) => (
<Card.Root key={plan} role="listitem">
{plan}
</Card.Root>
))}
</Grid.Root>
);
}
Fill
minItemSize is the narrowest a column may get. As many columns fit as the width allows, so the grid reflows without a media query, and a single column never overflows a container narrower than minItemSize.
import { Card } from '@tounsoo/todae/card';
import { Grid } from '@tounsoo/todae/grid';
const PLANS = ['Free', 'Team', 'Business', 'Enterprise'];
export default function GridFill() {
return (
<Grid.Root minItemSize="10rem" role="list" aria-label="Plans">
{PLANS.map((plan) => (
<Card.Root key={plan} role="listitem">
{plan}
</Card.Root>
))}
</Grid.Root>
);
}
For any other track list, such as a sidebar and a main column, leave both out and set gridTemplateColumns in style or a class.
Accessible composition
Todae handles: Layout only. Grid.Root renders a div with no role, and there is no as prop. Items are placed in DOM order: columns and minItemSize change how many fit in a row, never which comes first, so reading and Tab order follow what is drawn. Every other prop, ref, role and aria-* included, reaches the div.
You supply: The semantics. Items that form a list for the reader, such as plan cards, take role="list" on the Grid.Root and role="listitem" on each child; a Card.Root passes the role on. Give the group a heading before it when the reader needs to know what the items are.
Watch for: Moving items on screen with CSS: order, grid-auto-flow: dense or explicit grid-row and grid-column placement change where an item shows, not where it is read or reached by Tab. Put items in the DOM in the order they should be read. role="grid" on a layout grid: that role promises an interactive data grid with arrow-key navigation, which Grid.Root does not provide. Tabular data goes in a table.
When to use
When: Items laid out in rows and columns at once: cards, tiles, a form in two columns.
When not: One row or one column → Stack. Tabular data → a native table.
Props
| Name | Type | Description |
|---|---|---|
columns | number | A fixed number of equal columns, a whole number from 1. |
minItemSize | string | The narrowest a column may get, as a CSS length such as "12rem". As many columns fit as the width allows. |
children | React.ReactNode | Laid-out children. |