Playground

Grid

A responsive grid of equal columns with one gap.

  • Built on native elements
  • A plain div; source order is reading order.
  • Styles in one file: grid.css

Import

import '@monoline/css';
import {Grid} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add grid

Usage

import {Card, Grid} from '@monoline/react';

<Grid columns={3}>
  {['One', 'Two', 'Three'].map((n) => <Card key={n}>{n}</Card>)}
</Grid>

Examples

Three columns

Auto-fit

Props

GridProps

PropTypeDefaultDescription
columns1 | 2 | 3 | 4 | 5 | 6–Fixed number of equal columns. Omit for an auto-fit grid.
minColumnstring'16rem'With auto-fit: the smallest a column may be, as a CSS length such as `16rem`.
gap1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 94Step on the spacing scale, 1 to 9.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.gridgrid.css
.grid-fixedgrid.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.grid {
  border-color: var(--accent);
}

Accessibility

  • A plain div; source order is reading order.