Ask Rift AI
Theme: Smoke
Layout: Contained
Background: Field
Search or ask anythingAsk Rift AI
Theme: Smoke
Layout: Contained
Background: Field
Colour mode: System

Equal columns that fold by their own width

Grid runs its cells in equal columns, up to the number you set, and drops a column whenever one would get narrower than its floor. It measures itself rather than the window, so it folds the same beside an open sidebar as on a phone, and the cards in a row share its height.

Stat cards

This month1,284Active members+8%
This month342Orders+3%
This month2.4 daysAverage lead time
This month4.7Average rating-0.1

In a narrow column

One

Two

Three

Four

Alternatives

  • Use Stack instead when the children run in one line, a column or a row, rather than in equal columns.
  • Use Widget instead when the board is of Widget tiles of different heights that should pack without holes.

Props

Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.

Grid props
PropTypeDefaultDescription
columns
1 | 2 | 4 | 3 | 5 | 6
3
How many equal columns the grid runs to at full width. It folds to fewer as its own width narrows, never below `minColumnWidth`.
minColumnWidth
string
'12rem'
The narrowest a column may get before the grid drops one, as a CSS length (`16rem`). Defaults to `12rem`.
gap
StackGap
'500'
The space between cells, both ways, as a step on the gap scale (`--gap-500` by default).
align
"center" | "start" | "end" | "stretch"
'stretch'
How cells sit in their row: `stretch`, the default, makes every card in a row the same height.
as
"div" | "ol" | "section" | "ul"
'div'
The element the grid renders as, so a grid of cards can be a list.
children
ReactNode
The cells, in reading order.
className
string
''
Additional CSS classes

Keys

Nothing here takes focus, so there are no keys. A test holds that.

tsx
// From the npm package
import { Grid } from 'rift-ds/components/Grid/Grid';

// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/grid.json

0.3 kB gzipped, with everything it imports. Peer dependencies are not counted.

For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.