# List-detail

A list of items beside the details of the selected one, stacked on narrow screens.

**Our choice:** No standard exists: real links beside a detail region, placed with CSS grid, so history and URLs keep working.

_Diagram: List-detail splits the content area into a list of items and, beside it, the details of the selected one._

## Live example

### Orders and the selected order

```html
<div data-list-detail>
  <nav aria-label="Orders">
    <ul>
      <li><a href="?order=1042" aria-current="page">Order 1042 <small>Ada Lovelace · €1,240.00</small></a></li>
      <li><a href="?order=1041">Order 1041 <small>Alan Turing · €48.50</small></a></li>
      <li><a href="?order=1040">Order 1040 <small>Grace Hopper · €310.25</small></a></li>
      <li><a href="?order=1039">Order 1039 <small>Katherine Johnson · €72.00</small></a></li>
      <li><a href="?order=1038">Order 1038 <small>Hedy Lamarr · €615.90</small></a></li>
      <li><a href="?order=1037">Order 1037 <small>Margaret Hamilton · €2,105.00</small></a></li>
    </ul>
  </nav>
  <section aria-labelledby="order-1042-title" tabindex="0">
    <h3 id="order-1042-title">Order 1042</h3>
    <p><span data-badge="success">Shipped</span> Placed on 12 March 2025 by Ada Lovelace, Analytical Engines Ltd.</p>
    <dl>
      <dt>Ship to</dt>
      <dd>12 St James's Square, London SW1Y 4JH</dd>
      <dt>Carrier</dt>
      <dd>DHL Express, tracking 4207 1893 22</dd>
      <dt>Payment</dt>
      <dd>Invoice INV-2025-0318, due 11 April 2025</dd>
    </dl>
    <section data-scroll="inline" aria-labelledby="order-1042-lines" tabindex="0">
      <table>
        <caption id="order-1042-lines">Order lines</caption>
        <thead>
          <tr><th scope="col">Item</th><th scope="col">Quantity</th><th scope="col">Price</th><th scope="col">Total</th></tr>
        </thead>
        <tbody>
          <tr><td>Brass gear set</td><td>4</td><td>€180.00</td><td>€720.00</td></tr>
          <tr><td>Punch card reader</td><td>1</td><td>€440.00</td><td>€440.00</td></tr>
          <tr><td>Shipping</td><td>1</td><td>€80.00</td><td>€80.00</td></tr>
        </tbody>
      </table>
    </section>
    <p class="cluster">
      <a href="?order=1042&amp;view=new-invoice" data-button>Create invoice</a>
      <a href="?order=1042&amp;view=packing-slip" data-button>Print packing slip</a>
    </p>
  </section>
</div>
```

### Customers, compact

```html
<div data-list-detail data-density="compact">
  <nav aria-label="Customers">
    <ul>
      <li><a href="?customer=c-118" aria-current="page">Analytical Engines Ltd. <small>London</small></a></li>
      <li><a href="?customer=c-117">Bletchley Instruments <small>Milton Keynes</small></a></li>
      <li><a href="?customer=c-116">Cobol Systems BV <small>Utrecht</small></a></li>
      <li><a href="?customer=c-115">Orbital Mechanics GmbH <small>Bremen</small></a></li>
    </ul>
  </nav>
  <article aria-labelledby="customer-118-title">
    <h3 id="customer-118-title">Analytical Engines Ltd.</h3>
    <dl>
      <dt>Contact</dt>
      <dd>Ada Lovelace, ada@analytical-engines.example</dd>
      <dt>Payment terms</dt>
      <dd>30 days net</dd>
      <dt>Open balance</dt>
      <dd>€1,240.00 (one invoice)</dd>
    </dl>
    <p><a href="?customer=c-118&amp;view=orders">All orders from Analytical Engines Ltd.</a></p>
  </article>
</div>
```

### Settings page

```html
<div data-list-detail>
  <nav aria-label="Settings sections">
    <ul>
      <li><a href="#settings-company">Company</a></li>
      <li><a href="#settings-invoicing">Invoicing</a></li>
      <li><a href="#settings-notifications">Notifications</a></li>
    </ul>
  </nav>
  <section aria-labelledby="settings-title" tabindex="0">
    <h3 id="settings-title">Settings</h3>
    <form data-form-sections aria-labelledby="settings-title">
      <section id="settings-company" aria-labelledby="settings-company-title">
        <header>
          <h4 id="settings-company-title">Company</h4>
          <p>Shown on invoices, quotes and delivery notes.</p>
        </header>
        <div>
            <div data-field>
              <label for="set-name">Legal name</label>
              <input type="text" id="set-name" name="name" value="Domestic Trading Ltd." autocomplete="organization">
            </div>
            <div data-field>
              <label for="set-vat">VAT number</label>
              <input type="text" id="set-vat" name="vat" value="NL 8123 4567 B01" autocomplete="off">
            </div>
            <div data-field>
              <label for="set-iban">IBAN</label>
              <input type="text" id="set-iban" name="iban" value="NL91 ABNA 0417 1643 00" autocomplete="off">
            </div>
        </div>
      </section>
      <section id="settings-invoicing" aria-labelledby="settings-invoicing-title">
        <header>
          <h4 id="settings-invoicing-title">Invoicing</h4>
          <p>Defaults for new invoices; each invoice can change them.</p>
        </header>
        <div>
            <div data-field>
              <label for="set-terms">Default payment terms</label>
              <select id="set-terms" name="terms">
                <option>14 days net</option>
                <option selected>30 days net</option>
                <option>60 days net</option>
              </select>
            </div>
            <div data-field>
              <label for="set-prefix">Invoice number prefix</label>
              <input type="text" id="set-prefix" name="prefix" value="INV-2025-" autocomplete="off" aria-describedby="set-prefix-hint">
              <p id="set-prefix-hint" data-field-hint>The next invoice is INV-2025-0319.</p>
            </div>
            <div data-field>
              <label for="set-footer">Invoice footer</label>
              <textarea id="set-footer" name="footer">Thank you for your business. Please quote the invoice number with your payment.</textarea>
            </div>
        </div>
      </section>
      <section id="settings-notifications" aria-labelledby="settings-notifications-title">
        <header>
          <h4 id="settings-notifications-title">Notifications</h4>
          <p>Emails sent to the finance team.</p>
        </header>
        <fieldset>
          <legend>Email me when</legend>
          <label><input type="checkbox" name="notify-overdue" checked> An invoice is overdue</label>
          <label><input type="checkbox" name="notify-paid" checked> An invoice is paid</label>
          <label><input type="checkbox" name="notify-credit"> A credit note is issued</label>
        </fieldset>
      </section>
      <footer data-action-bar>
        <button type="submit">Save settings</button>
        <button type="reset">Discard changes</button>
      </footer>
    </form>
  </section>
</div>
```

## Attributes

| Attribute or value | Where | Effect |
| --- | --- | --- |
| `data-list-detail` | the wrapper | the list beside (or above) the detail |
| `<nav aria-label> or <div>` |  | first child: the list, a `<ul>` or `<ol>` whose items are each one `<a href>` (or `<button>`) |
| `<section> or <article> with aria-labelledby` |  | second child: the detail |
| `aria-current="page"` | the selected link, or its `<li>` | the selected item |
| `aria-current="true"` | the selected `<button>`, or its `<li>` | the selected item |

### Breakpoint

40rem of the wrapper's own inline size. A container query condition cannot read a custom property, so it is written as a length; to move it, write your own @container dui-list-detail rule.

### Keyboard

| Key | Action |
| --- | --- |
| <kbd>Tab</kbd> | moves through the list links, then into the detail pane |
| <kbd>Enter</kbd> | on a link, opens that item's detail |
| <kbd>Arrow keys</kbd> | scroll the detail pane once it has focus |

## Accessibility

- Use buttons only when the detail has no URL of its own (a picker inside a dialog), with aria-current="true" on the selected one.
- It is shown like a selected data table row: a --dui-border-width-emphasis accent bar on its leading edge, a tint and bold text, so color is not the only cue (WCAG 1.4.1) and the bar has 3:1 against the surface (WCAG 1.4.11).
- In forced colors mode the tint is dropped by the browser and the bar is drawn in Highlight, so the marker stays.
- Rows are at least --dui-size-row tall (32px, 28px compact, 44px on touch; WCAG 2.5.8).
- Give it tabindex="0" when it can scroll, so keyboard users can scroll it (WCAG 2.1.1).
- Source order is list, then detail, which is also the reading and Tab order in both layouts (WCAG 1.3.2, 2.4.3).
- When a link loads a new detail, move focus to the detail's heading or leave it on the link; never move it without a page load.

## Specifications

- [MDN CSS grid layout](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Grid_layout)
- [WCAG 1.4.10 Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html)
- [MDN Container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Containment/Container_queries)
- [MDN `aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-current)
- [WCAG Meaningful sequence](https://www.w3.org/WAI/WCAG22/Understanding/meaningful-sequence.html)
- [WCAG Use of color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html)
- [WCAG Non text contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html)
- [MDN `forced-colors`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors)

## See also

- [Layouts](https://domestic-ui.odonckers.dev/layouts/index.md)
- Source: [`css/layout/list-detail.css`](https://github.com/odonckers/domestic-ui/blob/main/css/layout/list-detail.css), [`examples/layouts/list-detail.html`](https://github.com/odonckers/domestic-ui/blob/main/examples/layouts/list-detail.html)
- Demos: Orders view ([Plain HTML](https://github.com/odonckers/domestic-ui/blob/main/demos/vanilla/orders.html), [React](https://github.com/odonckers/domestic-ui/blob/main/demos/react/src/OrdersPage.tsx), [Angular](https://github.com/odonckers/domestic-ui/tree/main/demos/angular/src/app/orders), [Astro](https://github.com/odonckers/domestic-ui/blob/main/demos/astro/src/pages/orders.astro), [Vue](https://github.com/odonckers/domestic-ui/blob/main/demos/vue/src/OrdersPage.vue), [Svelte](https://github.com/odonckers/domestic-ui/blob/main/demos/svelte/src/OrdersPage.svelte))

## How other systems do it

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

- [Apple Human Interface Guidelines: Split views](https://developer.apple.com/design/human-interface-guidelines/split-views)
- [Material Design 3: Canonical layout examples: List-detail](https://m3.material.io/foundations/layout/canonical-examples/list-detail)
- Vercel Geist: No equivalent
