Layout and grid

Set page width, columns, gap and breakpoints. Use library CSS classes and customise layout details with local CSS.

How layout works

  • wl-container centres the page and sets the gutter. Use narrow, fluid and full modifiers for reading, wide work areas and edge-to-edge sections.
  • wl-grid uses CSS Grid: repeat(auto-fit, minmax(min(100%, var(--wl-layout-grid-min)), 1fr)). The default minimum column width is 240 px; column count depends on the container's own width.
  • auto-fit divides available space equally between occupied columns. Use local grid-template-columns for specific proportions, or local grid-column: span N for a 12-column grid.
  • data-space changes the gap in stack, inline and grid. Gap is the space between elements; padding is inside a block; margin is outside it.
  • Media queries respond to viewport width. Check results inside sidebars and nested cards: a narrow container may need different conditions or auto-fit.
  • Preserve DOM order when adapting layout. minmax(0, 1fr), min-width: 0 and wrapping long text prevent overflow; place wide tables in a named scrollable region.
  • z-index works within a stacking context. Use a --wl-layer-* level, limit local composition with wl-isolate, and check whether ancestors introduce transform, opacity or isolation.

Import legato-ui/styles/primitives.css after base.css. Examples and copyable code use the same SFC. Appearance comes from the selected theme.

Responsive breakpoints

sm: 640 pxmd: 900 pxlg: 1200 px

Start with one column. Add two or three where content has enough space; media queries describe viewport width, while auto-fit uses available grid width.

Use numeric boundaries from wlBreakpoints in media queries; CSS custom properties cannot be used in conditions. A regular media query is enough for local CSS; no resize listener is needed.

Containers and page width

Four wl-container variants: a constrained page, a narrow reading column, fluid with a gutter, and edge-to-edge full. Bars show side spacing.

Default

wl-container

Centering, page-max and side gutter.

Reading

wl-container--narrow

Maximum --wl-layout-reading-max: suitable for an article or instructions.

Wide workspace

wl-container--fluid

All available width; side spacing is preserved.

Edge to edge

wl-container--full

No width limit or gutter; the content supplies its own padding.

Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <section class="container-example wl-stack" data-space="lg">
    <div class="container-example-band">
      <div class="wl-container">
        <div class="container-example-body">
          <h3 class="wl-text-label">{{ "Default" }}</h3>
          <code>wl-container</code>
          <p class="wl-text-small">{{ "Centering, page-max and side gutter." }}</p>
        </div>
      </div>
    </div>
    <div class="container-example-band">
      <div class="wl-container wl-container--narrow">
        <div class="container-example-body">
          <h3 class="wl-text-label">{{ "Reading" }}</h3>
          <code>wl-container--narrow</code>
          <p class="wl-text-small">{{ "Maximum --wl-layout-reading-max: suitable for an article or instructions." }}</p>
        </div>
      </div>
    </div>
    <div class="container-example-band">
      <div class="wl-container wl-container--fluid">
        <div class="container-example-body">
          <h3 class="wl-text-label">{{ "Wide workspace" }}</h3>
          <code>wl-container--fluid</code>
          <p class="wl-text-small">{{ "All available width; side spacing is preserved." }}</p>
        </div>
      </div>
    </div>
    <div class="container-example-band">
      <div class="wl-container wl-container--full">
        <div class="container-example-body">
          <h3 class="wl-text-label">{{ "Edge to edge" }}</h3>
          <code>wl-container--full</code>
          <p class="wl-text-small">{{ "No width limit or gutter; the content supplies its own padding." }}</p>
        </div>
      </div>
    </div>
  </section>
</template>

<style scoped>
.container-example { min-width: 0; }
.container-example-band { background: var(--wl-accent-soft); border: 1px dashed var(--wl-accent); min-width: 0; }
.container-example-body {
  min-width: 0;
  background: var(--wl-bg-soft);
  color: var(--wl-text);
  padding: var(--wl-space-md);
  display: grid;
  gap: var(--wl-space-sm);
  overflow-wrap: anywhere;
}
.container-example code { font: var(--wl-type-code-size)/var(--wl-type-code-line-height) var(--wl-mono); }
</style>

Equal columns: auto-fit

The basic wl-grid chooses how many equal columns fit with a --wl-layout-grid-min minimum. Resize the window: cards rearrange without JavaScript or media queries.

Column 1

Equal-width cards, each at least --wl-layout-grid-min wide.

The gap comes from data-space="lg". The last row retains the same columns.

Column 2

Equal-width cards, each at least --wl-layout-grid-min wide.

The gap comes from data-space="lg". The last row retains the same columns.

Column 3

Equal-width cards, each at least --wl-layout-grid-min wide.

The gap comes from data-space="lg". The last row retains the same columns.

Column 4

Equal-width cards, each at least --wl-layout-grid-min wide.

The gap comes from data-space="lg". The last row retains the same columns.

Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <div class="wl-grid" data-space="lg">
    <article
      v-for="number in 4"
      :key="number"
      class="wl-surface wl-stack"
      data-space="sm"
    >
      <h3 class="wl-text-subheading">{{ "Column" }} {{ number }}</h3>
      <p class="wl-text-body">{{ "Equal-width cards, each at least --wl-layout-grid-min wide." }}</p>
      <p class="wl-text-small wl-text-muted">{{ "The gap comes from data-space=\"lg\". The last row retains the same columns." }}</p>
    </article>
  </div>
</template>

Proportions and 12 columns

A local 12-column grid gives 8 + 4 and 6 + 6 layouts. On a narrow screen, blocks span all 12 columns. Example classes belong to the application.

8 of 12

The main block occupies two thirds of the width.

6 of 12

6 of 12

One span is one of 12 available columns after subtracting gap. Below 900 px, each block occupies the full row.

Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <section class="wl-stack" data-space="lg">
    <div class="proportion-example wl-grid" data-space="md">
      <article class="proportion-example-wide wl-surface wl-stack" data-space="sm">
        <h3 class="wl-text-subheading">{{ "8 of 12" }}</h3>
        <p class="wl-text-body">{{ "The main block occupies two thirds of the width." }}</p>
      </article>
      <aside class="proportion-example-aside wl-surface wl-stack" data-space="sm">
        <h3 class="wl-text-subheading">{{ "4 of 12" }}</h3>
        <p class="wl-text-body">{{ "Explanations and additional actions." }}</p>
      </aside>
      <article class="proportion-example-half wl-surface"><h3 class="wl-text-label">{{ "6 of 12" }}</h3></article>
      <article class="proportion-example-half wl-surface"><h3 class="wl-text-label">{{ "6 of 12" }}</h3></article>
    </div>
    <p class="wl-text-small wl-text-muted">{{ "One span is one of 12 available columns after subtracting gap. Below 900 px, each block occupies the full row." }}</p>
  </section>
</template>

<style scoped>
/* The application defines its own column proportions. */
.proportion-example { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.proportion-example-wide, .proportion-example-aside, .proportion-example-half { grid-column: span 12; min-width: 0; }
@media (min-width: 900px) {
  .proportion-example-wide { grid-column: span 8; }
  .proportion-example-aside { grid-column: span 4; }
  .proportion-example-half { grid-column: span 6; }
}
</style>

Viewport adaptation

Local CSS adjusts wl-grid: one column, two from sm 640 px, and three from md 900 px. wl-inline actions wrap; selecting a card changes local status.

Research

Cards adapt to the available width and preserve reading order.

Design

Cards adapt to the available width and preserve reading order.

Review

Cards adapt to the available width and preserve reading order.

Select a card. Actions wrap to the next line.

Vue SFC · application example
<script setup lang="ts">
import { WlButton } from "legato-ui";
import { ref } from "vue";
const projects = ["Research", "Design", "Review"];
const selected = ref("");
</script>

<template>
  <section class="wl-stack" data-space="xl">
    <div class="responsive-example-grid wl-grid" data-space="lg">
      <article
        v-for="project in projects"
        :key="project"
        class="wl-surface wl-stack"
        data-space="md"
      >
        <h3 class="wl-text-subheading">{{ project }}</h3>
        <p class="wl-text-body wl-text-muted">{{ "Cards adapt to the available width and preserve reading order." }}</p>
        <div>
          <WlButton size="sm" :aria-label="'Select ' + project" @click="selected = project">
            {{ "Select" }}
          </WlButton>
        </div>
      </article>
    </div>
    <div class="wl-inline" data-space="sm">
      <WlButton variant="primary" @click="selected = 'New project'">{{ "Add project" }}</WlButton>
      <WlButton @click="selected = ''">{{ "Reset selection" }}</WlButton>
    </div>
    <p class="wl-text-small wl-text-muted" role="status">
      {{ selected ? "Selected: " + selected : "Select a card. Actions wrap to the next line." }}
    </p>
  </section>
</template>

<style scoped>
/* The public primitive uses auto-fit; this application chooses explicit viewport tiers. */
.responsive-example-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .responsive-example-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .responsive-example-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
</style>

Gaps and alignment

data-space sets the gap between cards; align-items aligns them at the start, centre or stretch. Change settings and compare card positions.

Short card

One short thought.

More content

This card has more text. The tallest card determines the row height.

Stretch extends adjacent cards; start and center preserve their own height.

Gap: lg · align-items: stretch

Vue SFC · application example
<script setup lang="ts">
import { WlSelect } from "legato-ui";
import { ref } from "vue";
const space = ref("lg");
const alignment = ref("stretch");
const spaceOptions = ["sm", "md", "lg", "xl", "2xl"];
const alignmentOptions = [
  { label: "Start", value: "start" },
  { label: "Center", value: "center" },
  { label: "Stretch", value: "stretch" }
];
</script>

<template>
  <section class="wl-stack" data-space="lg">
    <div class="alignment-example-controls wl-grid" data-space="md">
      <div class="wl-stack" data-space="xs"><label for="layout-gap" class="wl-text-label">{{ "Gap" }}</label><WlSelect
        id="layout-gap"
        v-model="space"
        aria-label="Gap"
        :options="spaceOptions"
      /></div>
      <div class="wl-stack" data-space="xs">
        <label for="layout-alignment" class="wl-text-label">{{ "Alignment" }}</label>
        <WlSelect
          id="layout-alignment"
          v-model="alignment"
          aria-label="Alignment"
          :options="alignmentOptions"
          option-label="label"
          option-value="value"
        />
      </div>
    </div>
    <div class="alignment-example-grid wl-grid" :data-space="space" :style="{ alignItems: alignment }">
      <article class="wl-surface wl-stack" data-space="sm">
        <h3 class="wl-text-subheading">{{ "Short card" }}</h3>
        <p class="wl-text-body">{{ "One short thought." }}</p>
      </article>
      <article class="wl-surface wl-stack" data-space="sm">
        <h3 class="wl-text-subheading">{{ "More content" }}</h3>
        <p class="wl-text-body">{{ "This card has more text. The tallest card determines the row height." }}</p>
        <p class="wl-text-small wl-text-muted">
          {{ "Stretch extends adjacent cards; start and center preserve their own height." }}
        </p>
      </article>
    </div>
    <p class="wl-text-small wl-text-muted" role="status">Gap: {{ space }} · align-items: {{ alignment }}</p>
  </section>
</template>

<style scoped>
.alignment-example-controls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.alignment-example-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .alignment-example-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
</style>

Nested grid

The outer grid places sections; the inner grid places items in one section. Each wl-grid calculates columns from its own available width and uses its own data-space.

In progress

Material 1

The inner grid depends on this group's width.

Material 2

The inner grid depends on this group's width.

In review

Material 1

The inner grid depends on this group's width.

Material 2

The inner grid depends on this group's width.

Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <div class="wl-grid" data-space="xl">
    <section
      v-for="category in ['In progress', 'In review']"
      :key="category"
      class="wl-surface wl-stack"
      data-space="lg"
    >
      <h3 class="wl-text-subheading">{{ category }}</h3>
      <div class="wl-grid" data-space="sm">
        <article
          v-for="number in 2"
          :key="number"
          class="nested-example-item wl-stack"
          data-space="sm"
        >
          <h4 class="wl-text-label">{{ "Material" }} {{ number }}</h4>
          <p class="wl-text-small">{{ "The inner grid depends on this group's width." }}</p>
        </article>
      </div>
    </section>
  </div>
</template>

<style scoped>
.nested-example-item {
  min-width: 0;
  padding: var(--wl-space-md);
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-corner-control);
  background: var(--wl-bg-soft);
}
</style>

Sidebar and main area

A local sidebar + minmax(0, 1fr) grid builds a working page; below md, regions stack in their original DOM order.

All materials

Choose a section in the sidebar; its content appears in the main area.

Instructions

The area order is preserved on mobile.

Template

The main column can shrink thanks to minmax(0, 1fr).

Section: All materials

Vue SFC · application example
<script setup lang="ts">
import { WlButton } from "legato-ui";
import { ref } from "vue";
const folders = ["All materials", "My materials", "Archive"];
const selected = ref("All materials");
</script>

<template>
  <div class="composition-example wl-grid" data-space="lg">
    <aside class="wl-surface wl-stack" data-space="md" aria-label="Material sections">
      <h3 class="wl-text-subheading">{{ "Materials" }}</h3>
      <WlButton
        v-for="folder in folders"
        :key="folder"
        block
        :variant="selected === folder ? 'primary' : 'ghost'"
        :aria-pressed="selected === folder"
        @click="selected = folder"
      >{{ folder }}</WlButton>
    </aside>
    <section class="wl-surface wl-stack" data-space="lg">
      <header class="wl-stack" data-space="sm">
        <h3 class="wl-text-subheading">{{ selected }}</h3>
        <p class="wl-text-body wl-text-muted">
          {{ "Choose a section in the sidebar; its content appears in the main area." }}
        </p>
      </header>
      <div class="wl-grid" data-space="md">
        <article class="composition-example-card wl-stack" data-space="sm">
          <h4 class="wl-text-label">{{ "Instructions" }}</h4>
          <p class="wl-text-small">{{ "The area order is preserved on mobile." }}</p>
        </article>
        <article class="composition-example-card wl-stack" data-space="sm">
          <h4 class="wl-text-label">{{ "Template" }}</h4>
          <p class="wl-text-small">{{ "The main column can shrink thanks to minmax(0, 1fr)." }}</p>
        </article>
      </div>
      <p class="wl-text-small wl-text-muted" role="status">{{ "Section:" }} {{ selected }}</p>
    </section>
  </div>
</template>

<style scoped>
.composition-example { grid-template-columns: minmax(0, 1fr); }
.composition-example-card {
  min-width: 0;
  padding: var(--wl-space-md);
  border-radius: var(--wl-corner-control);
  background: var(--wl-bg-soft);
}
@media (min-width: 900px) { .composition-example { grid-template-columns: 200px minmax(0, 1fr); } }
</style>

Spacing scale

Spacing from wlSpacing: bar width comes from the selected theme's CSS token. Use one scale for gap, padding and margin.

none
--wl-space-none
2xs
--wl-space-2xs
xs
--wl-space-xs
sm
--wl-space-sm
md
--wl-space-md
lg
--wl-space-lg
xl
--wl-space-xl
2xl
--wl-space-2xl
3xl
--wl-space-3xl
4xl
--wl-space-4xl
Vue SFC · application example
<script setup lang="ts">
import { wlSpacing } from "legato-ui";
</script>

<template>
  <dl class="spacing-example wl-stack" data-space="md">
    <div v-for="(token, name) in wlSpacing" :key="name" class="spacing-example-row">
      <dt><code class="wl-text-code">{{ name }}</code></dt>
      <dd class="spacing-example-bar" :style="{ width: 'var(' + token + ')' }" aria-hidden="true"></dd>
      <dd class="spacing-example-token"><code class="wl-text-code">{{ token }}</code></dd>
    </div>
  </dl>
</template>

<style scoped>
.spacing-example { margin: 0; }
.spacing-example-row { display: grid; grid-template-columns: 40px 64px minmax(0, 1fr); align-items: center; gap: var(--wl-space-sm); }
.spacing-example-row dd { margin: 0; }
.spacing-example-bar { height: var(--wl-space-lg); background: var(--wl-accent); border-radius: var(--wl-corner-control); }
.spacing-example-token { overflow-wrap: anywhere; }
</style>

Surfaces, dividers and scrolling

wl-surface groups content, wl-rule separates sections, and wl-scroll-area contains a wide table. The scroll region has an accessible name and keyboard focus.

Material summary

The surface groups related parts. The divider separates the description from the data.


Materials: title, status and owner
TitleStatusOwner
Setup instructionsIn reviewInterface team
Workspace templateDoneProduct team

Tab focuses the table; arrow keys scroll it when space is limited. The rest of the page keeps its width.

Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <section class="wl-surface wl-stack" data-space="lg">
    <header class="wl-stack" data-space="sm">
      <h3 class="wl-text-subheading">{{ "Material summary" }}</h3>
      <p class="wl-text-small wl-text-muted">
        {{ "The surface groups related parts. The divider separates the description from the data." }}
      </p>
    </header>
    <hr class="wl-rule" />
    <div
      class="helpers-example-scroll wl-scroll-area"
      tabindex="0"
      role="region"
      aria-label="Material summary, scrollable table"
    >
      <table class="helpers-example-table">
        <caption class="wl-visually-hidden">{{ "Materials: title, status and owner" }}</caption>
        <thead>
          <tr>
            <th scope="col">{{ "Title" }}</th>
            <th scope="col">{{ "Status" }}</th>
            <th scope="col">{{ "Owner" }}</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">{{ "Setup instructions" }}</th>
            <td>{{ "In review" }}</td>
            <td>{{ "Interface team" }}</td>
          </tr>
          <tr>
            <th scope="row">{{ "Workspace template" }}</th>
            <td>{{ "Done" }}</td>
            <td>{{ "Product team" }}</td>
          </tr>
        </tbody>
      </table>
    </div>
    <p class="wl-text-small wl-text-muted">{{ "Tab focuses the table; arrow keys scroll it when space is limited. The rest of the page keeps its width." }}</p>
  </section>
</template>

<style scoped>
.helpers-example-scroll { border: 1px solid var(--wl-border); border-radius: var(--wl-corner-control); }
.helpers-example-scroll:focus-visible { outline: 2px solid var(--wl-focus-color); outline-offset: 2px; }
.helpers-example-table { width: 100%; min-width: 600px; border-collapse: collapse; text-align: left; font-size: var(--wl-type-small-size); }
.helpers-example-table th, .helpers-example-table td { padding: var(--wl-space-md); border-bottom: 1px solid var(--wl-border); }
.helpers-example-table thead { background: var(--wl-bg-soft); }
.helpers-example-table tbody tr:last-child th, .helpers-example-table tbody tr:last-child td { border-bottom: 0; }
</style>

Layers within a block

wl-isolate limits the stacking context to this illustration. Base, sticky and popover layers use library tokens. Overlap stays within the example.

The illustration uses isolation: isolate. Ordering applies within it; elements do not cover menus or other documentation content.

Vue SFC · application example
<script setup lang="ts">
import { resolveWlToken } from "legato-ui";
const layers = [
  { label: "Base", token: "--wl-layer-base" },
  { label: "Sticky", token: "--wl-layer-sticky" },
  { label: "Popover", token: "--wl-layer-popover" }
] as const;
</script>

<template>
  <section class="wl-stack" data-space="lg">
    <div
      class="layers-example wl-isolate"
      role="img"
      aria-label="Local layer overlap: base at the bottom, sticky in the middle, popover on top"
    >
      <div
        v-for="(layer, index) in layers"
        :key="layer.token"
        class="layers-example-card"
        :style="{
          zIndex: 'var(' + layer.token + ')',
          insetInlineStart: 'calc(var(--wl-space-lg) * ' + index + ')',
          top: 'calc(var(--wl-space-2xl) * ' + index + ')'
        }"
      >
        <h3 class="wl-text-label">{{ layer.label }} · {{ resolveWlToken(layer.token) }}</h3>
        <code class="wl-text-code">{{ layer.token }}</code>
      </div>
    </div>
    <p class="wl-text-small wl-text-muted">{{ "The illustration uses isolation: isolate. Ordering applies within it; elements do not cover menus or other documentation content." }}</p>
  </section>
</template>

<style scoped>
.layers-example {
  position: relative;
  min-width: 0;
  height: 260px;
  border: 1px dashed var(--wl-border);
  border-radius: var(--wl-corner-control);
  background: var(--wl-bg-soft);
}
.layers-example-card {
  position: absolute;
  width: calc(100% - var(--wl-space-2xl));
  min-width: 0;
  min-height: 128px;
  padding: var(--wl-space-md);
  display: grid;
  align-content: start;
  gap: var(--wl-space-sm);
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-corner-control);
  background: var(--wl-bg);
  color: var(--wl-text);
  overflow-wrap: anywhere;
  box-shadow: var(--wl-elevation-floating);
}
</style>

Layers and z-index

The levels below come from the current Legato UI token catalogue. For your own sticky block, use --wl-layer-sticky; change the shared layer through a token and constrain local overlap with wl-isolate.

RoleTokenLevelPurpose
Base content--wl-layer-base0Local base layer of the page.
Sticky--wl-layer-sticky50Sticky page regions.
Sidebar--wl-layer-navigation40Main desktop navigation.
Mask--wl-layer-mask70Dialog and modal overlay backdrop.
Popover--wl-layer-popover80Drawer, menu and popover panel.
Mobile navigation--wl-layer-navigation-modal90Sidebar in mobile modal mode.
Command palette--wl-layer-command90Search and quick navigation.
Filter panel--wl-layer-filter90Filter overlay.
Toast--wl-layer-toast100Notifications above other library layers.

A large value inside a child stacking context does not place an element above its parent. Transform, opacity below 1 and isolation create these contexts. Overlay components manage their own positioning and layers; do not raise the entire application to an arbitrary z-index.