# Grid

A responsive grid: as many columns as fit, each at least --grid-min wide, never wider than the container.

_Diagram: A grid lays out cards or panels in the content area in as many equal columns as fit, here three columns and two rows._

## Live example

### Grid

```html
<div class="grid" style="--grid-min: 12rem">
  <article data-card>
    <h4>Atoms</h4>
    <p>Native elements styled by the base layer, plus a few attributes.</p>
  </article>
  <article data-card>
    <h4>Molecules</h4>
    <p>Small groups of atoms, such as tabs, dialogs and cards.</p>
  </article>
  <article data-card>
    <h4>Organisms</h4>
    <p>Larger sections built from molecules. Coming later.</p>
  </article>
</div>
```

## API

| Attribute or value | Effect |
| --- | --- |
| `class="grid"` |  |
| `--grid-min` | minimum column width (default: `var(--dui-size-column-min)`) |
| `--grid-gap` | gap between cells (default: `var(--dui-space-l)`) |

No media queries. Pattern: "RAM" (repeat, auto-fit, minmax), see and "The Grid", Every Layout.

The custom properties do not inherit, so nested grids keep their defaults.

## Specifications

- [MDN `auto-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fit)
- [Every Layout grid](https://every-layout.dev/layouts/grid/)

## See also

- [Layouts](https://domestic-ui.odonckers.dev/layouts/index.md)
- [Component API convention](https://domestic-ui.odonckers.dev/index.md#component-api)
- [Accessibility baseline](https://domestic-ui.odonckers.dev/principles/accessibility-baseline-wcag-22-aa.md)
- Source: [`css/layout/grid.css`](https://github.com/odonckers/domestic-ui/blob/main/css/layout/grid.css), [`examples/base.html`](https://github.com/odonckers/domestic-ui/blob/main/examples/base.html)

## How other systems do it

For comparison only; these are not the standard this system follows.

- Apple Human Interface Guidelines: No equivalent
- Material Design 3: No equivalent
- Vercel Geist: No equivalent
