<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-zero/usage/ in the magma monorepo.
-->

# mds-zero - examples

> The API of this component: [`AGENTS.md`](AGENTS.md).

Correct and idiomatic ways to use the `<mds-zero>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md). Which panel an empty part takes, and what it says, is the pattern `empty-state`.

The title of the panel is written by its role, `typography="part"` (`titles/part` of the design language), with the `tag` of its place in the outline: `h2` under the title of the page, `h3` inside a section. Put the title and the description straight in `slot="content"`: the panel sets them apart itself.

#### Full Empty-State Panel

The canonical form, the first use: an illustration in the default slot, a title and a description in `slot="content"`, and the action that adds the first item in `slot="action"`.

```html
<mds-zero>
  <mds-img src="./assets/illustrations/empty-list.svg" alt=""></mds-img>
  <mds-text typography="part" tag="h2" slot="content">Nessuna delega</mds-text>
  <mds-text typography="detail" tag="p" slot="content">
    Con una delega un familiare o un professionista presenta le richieste a tuo nome.
    Aggiungi la prima per iniziare.
  </mds-text>
  <mds-button
    slot="action"
    label="Nuova delega"
    variant="primary"
    tone="strong"
    size="lg"
  ></mds-button>
</mds-zero>
```

#### Filled by Others (No Action)

When the person has nothing to do here, omit `slot="action"` entirely and say who fills the part, and when. The action zone takes no room, so the inset stays the same on every side.

```html
<mds-zero>
  <mds-img src="./assets/illustrations/empty-folder.svg" alt=""></mds-img>
  <mds-text typography="part" tag="h2" slot="content">Nessun documento</mds-text>
  <mds-text typography="detail" tag="p" slot="content">
    L'ufficio anagrafe aggiunge qui i documenti della pratica quando la prende in carico.
  </mds-text>
</mds-zero>
```

#### Message Without Illustration

When no illustration asset is available, omit the default slot. The component stacks the content and action zones directly.

```html
<mds-zero>
  <mds-text typography="part" tag="h2" slot="content">Nessun file</mds-text>
  <mds-text typography="detail" tag="p" slot="content">
    Carica i tuoi file per iniziare a condividerli con il team.
  </mds-text>
  <mds-button
    slot="action"
    label="Carica file"
    icon="mi/baseline/upload"
    variant="primary"
    tone="strong"
  ></mds-button>
</mds-zero>
```

#### Multiple Actions

When two peer actions are offered - for example a primary and a secondary CTA - place both `<mds-button>` elements in `slot="action"`. The action zone centers them and sets them `--magma-rhythm-inline` apart.

```html
<mds-zero>
  <mds-img src="./assets/illustrations/empty-inbox.svg" alt=""></mds-img>
  <mds-text typography="part" tag="h2" slot="content">Nessun messaggio</mds-text>
  <mds-text typography="detail" tag="p" slot="content">
    Inizia una nuova conversazione o invita i tuoi colleghi.
  </mds-text>
  <mds-button
    slot="action"
    label="Nuovo messaggio"
    variant="primary"
    tone="strong"
  ></mds-button>
  <mds-button
    slot="action"
    label="Invita colleghi"
    variant="primary"
    tone="outline"
  ></mds-button>
</mds-zero>
```

#### In Place of a Missing Page

When the panel takes the place of the whole page (the thing asked for does not exist), its title is the title of the page: `typography="page"` with `tag="h1"`, and its action leads back to the list.

```html
<main class="page-frame py-between-sections">
  <mds-zero>
    <mds-text typography="page" tag="h1" slot="content">Richiesta non trovata</mds-text>
    <mds-text typography="detail" tag="p" slot="content">
      La richiesta 2026/0412 non esiste: cercala nell'elenco delle richieste.
    </mds-text>
    <mds-button slot="action" label="Vai alle richieste" href="/richieste"></mds-button>
  </mds-zero>
</main>
```

#### Constraining the Text Block Width

Use `--mds-zero-contents-max-width` when the panel is wide and the default `400px` cap produces too narrow a text column, or when you want a tighter column on a compact layout.

```css
.wide-dashboard mds-zero {
  --mds-zero-contents-max-width: 560px;
}

.compact-sidebar mds-zero {
  --mds-zero-contents-max-width: 280px;
}
```

#### Overriding Zone Layout via Shadow Parts

Use `::part(contents)` or `::part(actions)` only when you need to change the zone's layout itself - for example aligning the content left inside a side-panel context. Prefer `--mds-zero-contents-max-width` for width adjustments.

```css
/* Left-align content for a narrow side panel */
.side-panel mds-zero::part(contents) {
  align-items: flex-start;
  text-align: left;
}
```
