# Empty state

What a list or table shows before it has anything in it, with the action that adds the first item.

**Our choice:** A composition, not a component: a `data-card` section with a heading, one muted sentence and a cluster of button links.

_Diagram: An empty state fills the content area where a list would be, with a heading, a sentence and the action that adds the first item._

## Live example

### Empty state

```html
<section data-card aria-labelledby="no-invoices">
  <h3 id="no-invoices">No invoices yet</h3>
  <p data-text="muted">Invoices you create or import show up here, with their status and amount due.</p>
  <p class="cluster">
    <a href="#new-invoice" data-button="primary">Create an invoice</a>
    <a href="#import" data-button="secondary">Import from CSV</a>
  </p>
</section>
```

## Accessibility

- Put the empty state where the list or table would be, under the same page heading, so the page keeps its structure.
- Say what will appear here and how to add it. The first action is the primary button; any other is secondary.
- After a search or filter that matches nothing, say so and offer to clear it, rather than suggesting the person create something.

## Specifications

- [HTML `<section>` element](https://html.spec.whatwg.org/multipage/sections.html#the-section-element)
- [WCAG 3.3.2 Labels or Instructions](https://www.w3.org/WAI/WCAG22/Understanding/labels-or-instructions.html)

## See also

- [Molecules](https://domestic-ui.odonckers.dev/molecules/index.md)
- Source: [`examples/patterns/compositions.html`](https://github.com/odonckers/domestic-ui/blob/main/examples/patterns/compositions.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: Empty State](https://vercel.com/geist/empty-state)
