# Layout

The band grid: a layout caps and centers its children; a child picks its band.

Source: https://www.zazz.sh/api/foundations/layout/

`data-ui="layout"` (or `<ui-layout>`) turns an element into the band grid for its own children. Each child sits in the default band, `xl`, unless placed elsewhere. A layout never styles its parent.

```html
<ui-layout style="--gap: 4">
  <ui-card style="--p: 4">Default band (xl)</ui-card>
  <ui-card
    style="
      --band: layout-md;
      --p: 4;
    "
  >
    --band: layout-md
  </ui-card>
  <ui-card
    style="
      --band: layout-bleed;
      --p: 4;
      --radius: 0;
    "
  >
    --band: layout-bleed
  </ui-card>
  <ui-card
    style="
      --band: layout-sm;
      --band--lg: layout-xl;
      --p: 4;
    "
  >
    --band: layout-sm, --band--lg: layout-xl
  </ui-card>
  <ui-layout data-layout-size="md" style="--band: layout-bleed">
    <ui-card style="--p: 4">nested layout, data-layout-size="md"</ui-card>
  </ui-layout>
</ui-layout>
```

## Bands

Bands share names with the breakpoints but are a separate rem scale, `--layout-sm` to `--layout-2xl` (40, 48, 64, 80, 96rem). Two more bands span wider: `layout-full` fills the layout minus the gutters, and `layout-bleed` runs edge to edge.

- Change the default for every child with `data-layout-size="md"`.
- Place one child with `--band: layout-md`; respond with `--band--lg: layout-xl`.
- A layout nested in a layout is a subgrid: it keeps the parent's band lines, so a bleed section can still align its content to the page bands.

## Children are containers

Each child of a layout is an inline-size query container, so breakpoint tiers inside a band follow the band's width rather than the full-width section around it. Nested layouts, subgridded children, and content-sized children (`fit-content`, `min-content`) stay uncontained. The hook `--ui-layout-child-container: normal` opts a layout's children out.

The gutters come from `--gutters` (default `--space-sm`). Hooks are listed on the [layout](/api/primitives/layout/) page.
