Grid
As many equal columns of at least min as fit. Items in a row grow to the tallest (cards line up, their footers at the foot); top keeps each at its own height, for a form beside a tall picture.
Preview
Harbour RoomSeats 8 · £40 an hour
Free now
Quay RoomSeats 4 · £25 an hour
Free at 14:00
Garden RoomSeats 12 · £55 an hour
Booked today
Use
The code of the preview above
import { Badge, Card, CardBody, Grid, ItemText, Row } from '@/components/ui';
<Grid min="10rem">
<Card>
<CardBody className="ui-stack ui-gap-2">
<ItemText title="Harbour Room" note="Seats 8 · £40 an hour" />
<Row>
<Badge tone="success" dot>
Free now
</Badge>
</Row>
</CardBody>
</Card>
<Card>
<CardBody className="ui-stack ui-gap-2">
<ItemText title="Quay Room" note="Seats 4 · £25 an hour" />
<Row>
<Badge tone="warning" dot>
Free at 14:00
</Badge>
</Row>
</CardBody>
</Card>
<Card>
<CardBody className="ui-stack ui-gap-2">
<ItemText title="Garden Room" note="Seats 12 · £55 an hour" />
<Row>
<Badge tone="outline">Booked today</Badge>
</Row>
</CardBody>
</Card>
</Grid>Options
| Option | Type | What it does |
|---|---|---|
gap | 1 | 2 | 3 | 4 | 6 | 8 | 12 | The space between the columns and rows; the page's gutter by default. |
min | string | The lowest value it allows. |
top | boolean | Keeps each item at its own height instead of growing to the tallest in its row. |
It also takes the 280 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
The same look on any HTML, with the classes ui-grid + --min, ui-grid--top.
Layout: states, do and don’t
Equal columns, as many as fit. Items in a row grow to the tallest, so cards line up with their footers at the foot; top keeps each at its own height (a form beside a tall picture).
States. Layout follows the box it is in, not the window: Split, Grid, AppShell and the site parts stack when their box is narrow, at any width of the window.
Do
- Space with
gap(Stack,Row,Grid), never with margins on children. - Put the page's sections straight on the page, under their titles; a
Cardis one thing a person picks or acts on. - Check every screen at 320, 375 and 768 px with the narrow check of rule 10.
Don't
- Don't give a box a fixed width, or a
min-heighttogether with anaspect-ratio. - Don't nest a card in a card.
- Don't put two
<main>s on a page: a screen shown inside another page takesMain as="div".