# Prebuilt themes

Four opt-in themes ship in `css/themes/`. `css/domestic.css` imports none of them. Link one after `css/domestic.css` and set `data-theme` to its name on `:root` or any element; scopes nest. Each file sets semantic tokens only, with light and dark values. How themes work and how to write your own: [Theming](https://domestic-ui.odonckers.dev/principles/theming.md).

```html
<html lang="en" data-theme="soft">
  <head>
    <link rel="stylesheet" href="css/domestic.css">
    <link rel="stylesheet" href="css/themes/soft.css">
  </head>
```

The theme menu in the app bar of these docs applies a theme to every page and remembers it in this browser.

## Live example

### Theme preview

```html
<section class="panel stack" aria-labelledby="preview-title">
  <h2 id="preview-title">Orders</h2>
  <p class="cluster">
    <button type="submit">Save</button>
    <button type="button" data-button="secondary">Export</button>
    <button type="button" data-button="quiet">Cancel</button>
    <button type="button" commandfor="preview-dialog" command="show-modal">Delete order…</button>
  </p>
  <div data-field>
    <label for="preview-customer">Customer</label>
    <input id="preview-customer" name="customer" type="text" value="Ada Lovelace" aria-describedby="preview-customer-hint">
    <p id="preview-customer-hint" data-field-hint>As it appears on the invoice.</p>
  </div>
  <p class="cluster">
    <span data-badge>Draft</span>
    <span data-badge="accent">New</span>
    <span data-badge="success">Paid</span>
    <span data-badge="danger">Overdue</span>
  </p>
  <dui-tabs>
    <nav aria-label="Order, preview">
      <ul>
        <li><a href="#preview-tab-items">Items</a></li>
        <li><a href="#preview-tab-history">History</a></li>
      </ul>
    </nav>
    <section id="preview-tab-items">
      <h3>Items</h3>
      <section data-scroll="inline" aria-labelledby="preview-caption" tabindex="0">
        <table data-table>
          <caption id="preview-caption">Items in order 1042</caption>
          <thead>
            <tr><th scope="col">Item</th><th scope="col" data-table-cell="number">Qty</th><th scope="col" data-table-cell="number">Total</th></tr>
          </thead>
          <tbody>
            <tr><td>Brass gears</td><td data-table-cell="number">12</td><td data-table-cell="number">€ 480.00</td></tr>
            <tr><td>Punched cards</td><td data-table-cell="number">500</td><td data-table-cell="number">€ 760.00</td></tr>
          </tbody>
        </table>
      </section>
    </section>
    <section id="preview-tab-history">
      <h3>History</h3>
      <p>Placed 12 March, shipped 14 March.</p>
    </section>
  </dui-tabs>
  <article data-card>
    <h3>Analytical Engines Ltd.</h3>
    <p>Customer since 2019 · 14 orders.</p>
  </article>
  <dialog id="preview-dialog" data-dialog closedby="any" aria-labelledby="preview-dialog-title">
    <header>
      <h2 id="preview-dialog-title">Delete order 1042?</h2>
    </header>
    <p>This cannot be undone.</p>
    <form method="dialog" class="cluster">
      <button type="submit" value="delete" data-button="danger">Delete order</button>
      <button type="submit" value="cancel" data-button="secondary">Cancel</button>
    </form>
  </dialog>
</section>
```

### Calm, soft and compact

```html
<div class="grid">
  <section class="panel stack" data-theme="calm" aria-labelledby="calm-title">
    <nav aria-label="Breadcrumb, calm theme" data-breadcrumb>
      <ol>
        <li><a href="#calm-title">Home</a></li>
        <li><a href="#calm-title">Releases</a></li>
        <li><a href="#calm-title" aria-current="page">Release notes</a></li>
      </ol>
    </nav>
    <h2 id="calm-title">Calm theme</h2>
    <p>Release notes are ready for review. <a href="#calm-title">Read the summary</a> before the meeting.</p>
    <p class="cluster">
      <span data-badge>Draft</span>
      <span data-badge="accent">New</span>
      <span data-badge="success">Passing</span>
      <span data-badge="warning">Review</span>
      <span data-badge="danger">Blocked</span>
    </p>
    <form action="#calm-title" class="stack">
      <div data-field>
        <label for="calm-email">Email</label>
        <input id="calm-email" name="email" type="email" autocomplete="email" value="ada@" aria-invalid="true" aria-describedby="calm-email-hint calm-email-error">
        <p id="calm-email-hint" data-field-hint>Release notes go to this address.</p>
        <p id="calm-email-error" data-field-error>Error: enter an email address like name@example.com.</p>
      </div>
      <label><input type="checkbox" role="switch" name="notify" checked> Notify subscribers</label>
      <div class="cluster">
        <button type="submit">Publish</button>
        <button type="button" data-button="secondary">Save draft</button>
        <button type="button" data-button="quiet">Discard</button>
      </div>
    </form>
    <div data-alert="warning">
      <p><strong>Warning:</strong> Two checks are still running.</p>
    </div>
    <dui-tabs>
      <nav aria-label="Release, calm theme">
        <ul>
          <li><a href="#calm-tab-notes">Notes</a></li>
          <li><a href="#calm-tab-checks">Checks</a></li>
        </ul>
      </nav>
      <section id="calm-tab-notes">
        <h3>Notes</h3>
        <p>Two bug fixes and a new token.</p>
      </section>
      <section id="calm-tab-checks">
        <h3>Checks</h3>
        <p>Lint passed. Tests are running.</p>
      </section>
    </dui-tabs>
    <article data-card="link">
      <h3><a href="#calm-title">Upgrade guide</a></h3>
      <p>What to change when you update.</p>
    </article>
    <details>
      <summary>What changed?</summary>
      <p>Two bug fixes and a new <code>--dui-color-success</code> token.</p>
    </details>
  </section>
  <section class="panel stack" data-theme="soft" aria-labelledby="soft-title">
    <nav aria-label="Breadcrumb, soft theme" data-breadcrumb>
      <ol>
        <li><a href="#soft-title">Home</a></li>
        <li><a href="#soft-title">Releases</a></li>
        <li><a href="#soft-title" aria-current="page">Release notes</a></li>
      </ol>
    </nav>
    <h2 id="soft-title">Soft theme</h2>
    <p>Release notes are ready for review. <a href="#soft-title">Read the summary</a> before the meeting.</p>
    <p class="cluster">
      <span data-badge>Draft</span>
      <span data-badge="accent">New</span>
      <span data-badge="success">Passing</span>
      <span data-badge="warning">Review</span>
      <span data-badge="danger">Blocked</span>
    </p>
    <form action="#soft-title" class="stack">
      <div data-field>
        <label for="soft-email">Email</label>
        <input id="soft-email" name="email" type="email" autocomplete="email" value="ada@" aria-invalid="true" aria-describedby="soft-email-hint soft-email-error">
        <p id="soft-email-hint" data-field-hint>Release notes go to this address.</p>
        <p id="soft-email-error" data-field-error>Error: enter an email address like name@example.com.</p>
      </div>
      <label><input type="checkbox" role="switch" name="notify" checked> Notify subscribers</label>
      <div class="cluster">
        <button type="submit">Publish</button>
        <button type="button" data-button="secondary">Save draft</button>
        <button type="button" data-button="quiet">Discard</button>
      </div>
    </form>
    <div data-alert="warning">
      <p><strong>Warning:</strong> Two checks are still running.</p>
    </div>
    <dui-tabs>
      <nav aria-label="Release, soft theme">
        <ul>
          <li><a href="#soft-tab-notes">Notes</a></li>
          <li><a href="#soft-tab-checks">Checks</a></li>
        </ul>
      </nav>
      <section id="soft-tab-notes">
        <h3>Notes</h3>
        <p>Two bug fixes and a new token.</p>
      </section>
      <section id="soft-tab-checks">
        <h3>Checks</h3>
        <p>Lint passed. Tests are running.</p>
      </section>
    </dui-tabs>
    <article data-card="link">
      <h3><a href="#soft-title">Upgrade guide</a></h3>
      <p>What to change when you update.</p>
    </article>
    <details>
      <summary>What changed?</summary>
      <p>Two bug fixes and a new <code>--dui-color-success</code> token.</p>
    </details>
  </section>
  <section class="panel stack" data-theme="neutral" aria-labelledby="neutral-title">
    <nav aria-label="Breadcrumb, neutral theme" data-breadcrumb>
      <ol>
        <li><a href="#neutral-title">Home</a></li>
        <li><a href="#neutral-title">Releases</a></li>
        <li><a href="#neutral-title" aria-current="page">Release notes</a></li>
      </ol>
    </nav>
    <h2 id="neutral-title">Neutral theme</h2>
    <p>Release notes are ready for review. <a href="#neutral-title">Read the summary</a> before the meeting.</p>
    <p class="cluster">
      <span data-badge>Draft</span>
      <span data-badge="accent">New</span>
      <span data-badge="success">Passing</span>
      <span data-badge="warning">Review</span>
      <span data-badge="danger">Blocked</span>
    </p>
    <form action="#neutral-title" class="stack">
      <div data-field>
        <label for="neutral-email">Email</label>
        <input id="neutral-email" name="email" type="email" autocomplete="email" value="ada@" aria-invalid="true" aria-describedby="neutral-email-hint neutral-email-error">
        <p id="neutral-email-hint" data-field-hint>Release notes go to this address.</p>
        <p id="neutral-email-error" data-field-error>Error: enter an email address like name@example.com.</p>
      </div>
      <label><input type="checkbox" role="switch" name="notify" checked> Notify subscribers</label>
      <div class="cluster">
        <button type="submit">Publish</button>
        <button type="button" data-button="secondary">Save draft</button>
        <button type="button" data-button="quiet">Discard</button>
      </div>
    </form>
    <div data-alert="warning">
      <p><strong>Warning:</strong> Two checks are still running.</p>
    </div>
    <dui-tabs>
      <nav aria-label="Release, neutral theme">
        <ul>
          <li><a href="#neutral-tab-notes">Notes</a></li>
          <li><a href="#neutral-tab-checks">Checks</a></li>
        </ul>
      </nav>
      <section id="neutral-tab-notes">
        <h3>Notes</h3>
        <p>Two bug fixes and a new token.</p>
      </section>
      <section id="neutral-tab-checks">
        <h3>Checks</h3>
        <p>Lint passed. Tests are running.</p>
      </section>
    </dui-tabs>
    <article data-card="link">
      <h3><a href="#neutral-title">Upgrade guide</a></h3>
      <p>What to change when you update.</p>
    </article>
    <details>
      <summary>What changed?</summary>
      <p>Two bug fixes and a new <code>--dui-color-success</code> token.</p>
    </details>
  </section>
  <section class="panel stack" data-theme="compact" aria-labelledby="compact-title">
    <nav aria-label="Breadcrumb, compact theme" data-breadcrumb>
      <ol>
        <li><a href="#compact-title">Home</a></li>
        <li><a href="#compact-title">Releases</a></li>
        <li><a href="#compact-title" aria-current="page">Release notes</a></li>
      </ol>
    </nav>
    <h2 id="compact-title">Compact theme</h2>
    <p>Release notes are ready for review. <a href="#compact-title">Read the summary</a> before the meeting.</p>
    <p class="cluster">
      <span data-badge>Draft</span>
      <span data-badge="accent">New</span>
      <span data-badge="success">Passing</span>
      <span data-badge="warning">Review</span>
      <span data-badge="danger">Blocked</span>
    </p>
    <form action="#compact-title" class="stack">
      <div data-field>
        <label for="compact-email">Email</label>
        <input id="compact-email" name="email" type="email" autocomplete="email" value="ada@" aria-invalid="true" aria-describedby="compact-email-hint compact-email-error">
        <p id="compact-email-hint" data-field-hint>Release notes go to this address.</p>
        <p id="compact-email-error" data-field-error>Error: enter an email address like name@example.com.</p>
      </div>
      <label><input type="checkbox" role="switch" name="notify" checked> Notify subscribers</label>
      <div class="cluster">
        <button type="submit">Publish</button>
        <button type="button" data-button="secondary">Save draft</button>
        <button type="button" data-button="quiet">Discard</button>
      </div>
    </form>
    <div data-alert="warning">
      <p><strong>Warning:</strong> Two checks are still running.</p>
    </div>
    <dui-tabs>
      <nav aria-label="Release, compact theme">
        <ul>
          <li><a href="#compact-tab-notes">Notes</a></li>
          <li><a href="#compact-tab-checks">Checks</a></li>
        </ul>
      </nav>
      <section id="compact-tab-notes">
        <h3>Notes</h3>
        <p>Two bug fixes and a new token.</p>
      </section>
      <section id="compact-tab-checks">
        <h3>Checks</h3>
        <p>Lint passed. Tests are running.</p>
      </section>
    </dui-tabs>
    <article data-card="link">
      <h3><a href="#compact-title">Upgrade guide</a></h3>
      <p>What to change when you update.</p>
    </article>
    <details>
      <summary>What changed?</summary>
      <p>Two bug fixes and a new <code>--dui-color-success</code> token.</p>
    </details>
  </section>
</div>
```

## Tokens each theme changes

Generated from the theme files and `css/tokens/semantic.css`.

### Calm

[`css/themes/calm.css`](https://github.com/odonckers/domestic-ui/blob/main/css/themes/calm.css), `data-theme="calm"`.

| Token | Default | Calm |
| --- | --- | --- |
| `--dui-color-accent` | `var(--dui-color-clay-9)` | `var(--dui-color-accent-indigo)` |
| `--dui-color-primary` | `light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12))` | `var(--dui-color-accent)` |
| `--dui-color-primary-hover` | `light-dark(oklch(from var(--dui-color-primary) 26% calc(c + 0.002) h), oklch(from var(--dui-color-primary) 90% calc(c + 0.004) h))` | `var(--dui-color-accent-hover)` |
| `--dui-color-primary-contrast` | `light-dark(var(--dui-color-neutral-2), var(--dui-color-neutral-dark-1))` | `var(--dui-color-accent-contrast)` |
| `--dui-color-shadow` | `light-dark(var(--dui-color-neutral-shadow), var(--dui-color-neutral-dark-shadow))` | `light-dark(oklch(32% 0.06 272deg / 14%), oklch(12% 0.04 272deg / 50%))` |

### Soft

[`css/themes/soft.css`](https://github.com/odonckers/domestic-ui/blob/main/css/themes/soft.css), `data-theme="soft"`.

| Token | Default | Soft |
| --- | --- | --- |
| `--dui-color-surface` | `light-dark(var(--dui-color-neutral-1), var(--dui-color-neutral-dark-1))` | `light-dark(oklch(99.2% 0.004 70deg), oklch(17% 0.006 70deg))` |
| `--dui-color-surface-raised` | `light-dark(var(--dui-color-neutral-2), var(--dui-color-neutral-dark-2))` | `light-dark(oklch(98% 0.006 70deg), oklch(19.5% 0.008 70deg))` |
| `--dui-color-surface-sunken` | `light-dark(var(--dui-color-neutral-3), var(--dui-color-neutral-dark-3))` | `light-dark(oklch(96% 0.008 70deg), oklch(22.5% 0.01 70deg))` |
| `--dui-color-surface-hover` | `light-dark(var(--dui-color-neutral-4), var(--dui-color-neutral-dark-4))` | `light-dark(oklch(93.8% 0.01 70deg), oklch(26.5% 0.012 70deg))` |
| `--dui-color-surface-active` | `light-dark(var(--dui-color-neutral-5), var(--dui-color-neutral-dark-5))` | `light-dark(oklch(90.8% 0.012 70deg), oklch(31.5% 0.014 70deg))` |
| `--dui-color-text` | `light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12))` | `light-dark(oklch(22% 0.014 70deg), oklch(95% 0.006 70deg))` |
| `--dui-color-text-muted` | `color-mix(in oklab, var(--dui-color-text) clamp(0%, (var(--dui-contrast) - 1) * 100%, 100%), light-dark(var(--dui-color-neutral-11), var(--dui-color-neutral-dark-11)))` | `light-dark(oklch(47% 0.018 70deg), oklch(76% 0.014 70deg))` |
| `--dui-color-border` | `light-dark(oklch(from var(--dui-color-neutral-12-a11) l c h / calc(alpha * var(--dui-contrast))), oklch(from var(--dui-color-neutral-dark-12-a10) l c h / calc(alpha * var(--dui-contrast))))` | `light-dark(oklch(22% 0.014 70deg / 11%), oklch(95% 0.006 70deg / 10%))` |
| `--dui-color-border-control` | `light-dark(var(--dui-color-neutral-8), var(--dui-color-neutral-dark-8))` | `light-dark(oklch(58% 0.018 70deg), oklch(58.5% 0.018 70deg))` |
| `--dui-color-border-control-hover` | `light-dark(var(--dui-color-neutral-9), var(--dui-color-neutral-dark-9))` | `light-dark(oklch(52% 0.018 70deg), oklch(66% 0.016 70deg))` |
| `--dui-color-border-button` | `light-dark(var(--dui-color-neutral-6), var(--dui-color-neutral-dark-6))` | `light-dark(oklch(72% 0.016 70deg), oklch(48% 0.016 70deg))` |
| `--dui-color-shadow` | `light-dark(var(--dui-color-neutral-shadow), var(--dui-color-neutral-dark-shadow))` | `light-dark(oklch(32% 0.03 50deg / 11%), oklch(12% 0.02 50deg / 48%))` |
| `--dui-color-accent` | `var(--dui-color-clay-9)` | `oklch(55% 0.15 40deg)` |
| `--dui-color-primary` | `light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12))` | `var(--dui-color-accent)` |
| `--dui-color-primary-hover` | `light-dark(oklch(from var(--dui-color-primary) 26% calc(c + 0.002) h), oklch(from var(--dui-color-primary) 90% calc(c + 0.004) h))` | `var(--dui-color-accent-hover)` |
| `--dui-color-primary-contrast` | `light-dark(var(--dui-color-neutral-2), var(--dui-color-neutral-dark-1))` | `var(--dui-color-accent-contrast)` |
| `--dui-radius-scale` | `var(--dui-factor-1)` | `1.5` |
| `--dui-density-scale` | `var(--dui-factor-1)` | `1.25` |
| `--dui-elevation-strength` | `var(--dui-mix-100)` | `80%` |

### Compact

[`css/themes/compact.css`](https://github.com/odonckers/domestic-ui/blob/main/css/themes/compact.css), `data-theme="compact"`.

| Token | Default | Compact |
| --- | --- | --- |
| `--dui-color-accent` | `var(--dui-color-clay-9)` | `oklch(53% 0.15 250deg)` |
| `--dui-radius-scale` | `var(--dui-factor-1)` | `0.25` |
| `--dui-density-scale` | `var(--dui-factor-1)` | `0` |
| `--dui-elevation-strength` | `var(--dui-mix-100)` | `35%` |

### Neutral

[`css/themes/neutral.css`](https://github.com/odonckers/domestic-ui/blob/main/css/themes/neutral.css), `data-theme="neutral"`.

| Token | Default | Neutral |
| --- | --- | --- |
| `--dui-color-surface` | `light-dark(var(--dui-color-neutral-1), var(--dui-color-neutral-dark-1))` | `light-dark(oklch(100% 0 0deg), oklch(14.5% 0 0deg))` |
| `--dui-color-surface-raised` | `light-dark(var(--dui-color-neutral-2), var(--dui-color-neutral-dark-2))` | `light-dark(oklch(98.5% 0 0deg), oklch(20.5% 0 0deg))` |
| `--dui-color-surface-sunken` | `light-dark(var(--dui-color-neutral-3), var(--dui-color-neutral-dark-3))` | `light-dark(oklch(97% 0 0deg), oklch(22% 0 0deg))` |
| `--dui-color-surface-hover` | `light-dark(var(--dui-color-neutral-4), var(--dui-color-neutral-dark-4))` | `light-dark(oklch(96% 0 0deg), oklch(26.9% 0 0deg))` |
| `--dui-color-surface-active` | `light-dark(var(--dui-color-neutral-5), var(--dui-color-neutral-dark-5))` | `light-dark(oklch(93.5% 0 0deg), oklch(31% 0 0deg))` |
| `--dui-color-surface-frame` | `var(--dui-color-surface)` | `var(--dui-color-surface-raised)` |
| `--dui-color-text` | `light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12))` | `light-dark(oklch(14.5% 0 0deg), oklch(98.5% 0 0deg))` |
| `--dui-color-text-muted` | `color-mix(in oklab, var(--dui-color-text) clamp(0%, (var(--dui-contrast) - 1) * 100%, 100%), light-dark(var(--dui-color-neutral-11), var(--dui-color-neutral-dark-11)))` | `color-mix(in oklab, var(--dui-color-text) clamp(0%, (var(--dui-contrast) - 1) * 100%, 100%), light-dark(oklch(50.5% 0 0deg), oklch(70.8% 0 0deg)))` |
| `--dui-color-border` | `light-dark(oklch(from var(--dui-color-neutral-12-a11) l c h / calc(alpha * var(--dui-contrast))), oklch(from var(--dui-color-neutral-dark-12-a10) l c h / calc(alpha * var(--dui-contrast))))` | `light-dark(oklch(14.5% 0 0deg / calc(11% * var(--dui-contrast))), oklch(98.5% 0 0deg / calc(10% * var(--dui-contrast))))` |
| `--dui-color-border-control` | `light-dark(var(--dui-color-neutral-8), var(--dui-color-neutral-dark-8))` | `light-dark(oklch(60% 0 0deg), oklch(58% 0 0deg))` |
| `--dui-color-border-control-hover` | `light-dark(var(--dui-color-neutral-9), var(--dui-color-neutral-dark-9))` | `light-dark(oklch(55.6% 0 0deg), oklch(65% 0 0deg))` |
| `--dui-color-border-button` | `light-dark(var(--dui-color-neutral-6), var(--dui-color-neutral-dark-6))` | `light-dark(oklch(92.2% 0 0deg), oklch(37.1% 0 0deg))` |
| `--dui-color-shadow` | `light-dark(var(--dui-color-neutral-shadow), var(--dui-color-neutral-dark-shadow))` | `light-dark(oklch(0% 0 0deg / 10%), oklch(0% 0 0deg / 46%))` |
| `--dui-color-accent` | `var(--dui-color-clay-9)` | `var(--dui-color-text)` |
| `--dui-color-primary` | `light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12))` | `var(--dui-color-text)` |
| `--dui-color-primary-contrast` | `light-dark(var(--dui-color-neutral-2), var(--dui-color-neutral-dark-1))` | `light-dark(oklch(100% 0 0deg), oklch(14.5% 0 0deg))` |
| `--dui-color-code-punctuation` | `light-dark(var(--dui-color-neutral-punctuation), var(--dui-color-neutral-dark-punctuation))` | `light-dark(oklch(37% 0 0deg), oklch(83.5% 0 0deg))` |
| `--dui-elevation-raised-surface` | `light-dark(var(--dui-color-surface-raised), var(--dui-elevation-1-surface))` | `var(--dui-elevation-1-surface)` |
| `--dui-elevation-panel-surface` | `light-dark(var(--dui-color-surface-raised), var(--dui-elevation-1-surface))` | `var(--dui-color-surface)` |
| `--dui-font-display` | `var(--dui-font-stack-transitional)` | `var(--dui-font-heading)` |
| `--dui-font-weight-display` | `var(--dui-font-weight-500)` | `var(--dui-font-weight-heading)` |
| `--dui-pattern-image` | `var(--dui-pattern-dots)` | `none` |
