domestic-ui GitHub

Compact density

A compact density token that tightens spacing for data-heavy screens.

Our choice: No standard exists: data-density="compact" on any ancestor re-derives the density tokens; text size never changes and targets stay at least 24 by 24 CSS pixels.

Where compact density is used Compact density tightens a data-heavy area such as a table, so it shows more rows in the same height than a comfortable table beside it.

Live example

Comfortable and compact

<div class="grid" style="--grid-min: 20rem">
  <section data-density="comfortable" class="panel stack" aria-labelledby="comfortable-title">
    <h3 id="comfortable-title">Comfortable (default)</h3>
    <dui-toolbar role="toolbar" aria-label="Order actions (comfortable)">
      <button type="button">New order</button>
      <button type="button">Export</button>
      <hr>
      <button type="button" aria-pressed="false">Show archived</button>
    </dui-toolbar>
    <form class="stack" aria-labelledby="comfortable-form-title comfortable-title">
      <h4 id="comfortable-form-title">Edit order</h4>
      <div data-field>
        <label for="comfortable-customer">Customer</label>
        <input type="text" id="comfortable-customer" name="customer" value="Ada Lovelace" autocomplete="off">
      </div>
      <div data-field>
        <label for="comfortable-status">Status</label>
        <select id="comfortable-status" name="status">
          <option>Open</option>
          <option selected>Shipped</option>
          <option>Delivered</option>
        </select>
      </div>
      <dui-combobox>
        <label for="comfortable-carrier">Carrier</label>
        <input type="text" id="comfortable-carrier" name="carrier" list="comfortable-carriers">
        <datalist id="comfortable-carriers">
          <option value="DHL Express"></option>
          <option value="DPD Classic"></option>
          <option value="PostNL Parcel"></option>
          <option value="UPS Standard"></option>
        </datalist>
      </dui-combobox>
      <label><input type="checkbox" name="notify" checked> Email the customer</label>
      <label><input type="checkbox" role="switch" name="priority"> Priority</label>
      <p class="cluster">
        <button type="submit">Save</button>
        <button type="reset">Reset</button>
      </p>
    </form>
    <section data-scroll="inline" aria-labelledby="comfortable-orders comfortable-title" tabindex="0">
      <table>
        <caption id="comfortable-orders">Recent orders</caption>
        <thead>
          <tr><th scope="col">Order</th><th scope="col">Customer</th><th scope="col">Status</th><th scope="col">Total</th></tr>
        </thead>
        <tbody>
          <tr><td>1042</td><td>Ada Lovelace</td><td>Shipped</td><td>€120.00</td></tr>
          <tr><td>1041</td><td>Alan Turing</td><td>Open</td><td>€48.50</td></tr>
          <tr><td>1040</td><td>Grace Hopper</td><td>Delivered</td><td>€310.25</td></tr>
          <tr><td>1039</td><td>Katherine Johnson</td><td>Delivered</td><td>€72.00</td></tr>
        </tbody>
      </table>
    </section>
  </section>
  <section data-density="compact" class="panel stack" aria-labelledby="compact-title">
    <h3 id="compact-title">Compact</h3>
    <dui-toolbar role="toolbar" aria-label="Order actions (compact)">
      <button type="button">New order</button>
      <button type="button">Export</button>
      <hr>
      <button type="button" aria-pressed="false">Show archived</button>
    </dui-toolbar>
    <form class="stack" aria-labelledby="compact-form-title compact-title">
      <h4 id="compact-form-title">Edit order</h4>
      <div data-field>
        <label for="compact-customer">Customer</label>
        <input type="text" id="compact-customer" name="customer" value="Ada Lovelace" autocomplete="off">
      </div>
      <div data-field>
        <label for="compact-status">Status</label>
        <select id="compact-status" name="status">
          <option>Open</option>
          <option selected>Shipped</option>
          <option>Delivered</option>
        </select>
      </div>
      <dui-combobox>
        <label for="compact-carrier">Carrier</label>
        <input type="text" id="compact-carrier" name="carrier" list="compact-carriers">
        <datalist id="compact-carriers">
          <option value="DHL Express"></option>
          <option value="DPD Classic"></option>
          <option value="PostNL Parcel"></option>
          <option value="UPS Standard"></option>
        </datalist>
      </dui-combobox>
      <label><input type="checkbox" name="notify" checked> Email the customer</label>
      <label><input type="checkbox" role="switch" name="priority"> Priority</label>
      <p class="cluster">
        <button type="submit">Save</button>
        <button type="reset">Reset</button>
      </p>
    </form>
    <section data-scroll="inline" aria-labelledby="compact-orders compact-title" tabindex="0">
      <table>
        <caption id="compact-orders">Recent orders</caption>
        <thead>
          <tr><th scope="col">Order</th><th scope="col">Customer</th><th scope="col">Status</th><th scope="col">Total</th></tr>
        </thead>
        <tbody>
          <tr><td>1042</td><td>Ada Lovelace</td><td>Shipped</td><td>€120.00</td></tr>
          <tr><td>1041</td><td>Alan Turing</td><td>Open</td><td>€48.50</td></tr>
          <tr><td>1040</td><td>Grace Hopper</td><td>Delivered</td><td>€310.25</td></tr>
          <tr><td>1039</td><td>Katherine Johnson</td><td>Delivered</td><td>€72.00</td></tr>
        </tbody>
      </table>
    </section>
  </section>
</div>

Comfortable inside compact

<div data-density="compact" class="panel stack">
  <p class="cluster">
    <button type="button">Compact button</button>
    <span data-density="comfortable"><button type="button">Comfortable button</button></span>
  </p>
</div>

Specifications

See also

How other systems do it

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

Search