# domestic-ui > domestic-ui is a CSS design system built on native HTML, custom properties and cascade layers. Link one stylesheet and semantic HTML is styled in light and dark, with WCAG 2.2 AA as the baseline. Theme it by overriding semantic tokens. It packages existing web standards and patterns. Nothing here is original. Link `css/domestic.css` (copy `css/` from the v0.1.0 release, https://github.com/odonckers/domestic-ui/releases/tag/v0.1.0); semantic HTML needs no classes. Components: one `data-` attribute of space-separated words matched with `~=` (`data-button="primary small"`), no classes; state via native attributes and ARIA. Layout primitives and utilities: `data-action-bar`, `.cluster`, `.grid`, `data-card`, `data-scroll`, `.stack`, `.visually-hidden`. Theme only with semantic `--dui-*` tokens; primitives are internal. Writing a page? Read [Writing pages with no CSS](https://domestic-ui.odonckers.dev/guides/writing-pages.md) first: the rules, a whole page to start from and every documented attribute, word, class and element. A page written to it needs no CSS of its own; `node scripts/check-markup.mjs page.html` checks that. ## Writing pages with no CSS Page: https://domestic-ui.odonckers.dev/guides/writing-pages.html A page built this way links one stylesheet and writes no CSS. Everything it looks like comes from the elements it uses, a few documented attributes, and the [tokens](https://domestic-ui.odonckers.dev/tokens/index.md) a theme sets. **Our choice:** a closed vocabulary rather than utility classes, so a page says what each part is, not how it should look, and a checker can tell when a page leaves the system. ### The rules 1. Link `css/domestic.css` once, in ``. Optionally link a theme from `css/themes/` after it and set `data-theme` on ``. 2. Write no ` ``` #### Radius scale ```html

Scale 0

A card

Square corners.

Scale 1

A card

The default corners.

Scale 1.5

A card

Rounder corners.

``` #### Contrast ```html

0.8

Body text. Muted text stays at 4.5:1.

New Overdue

Info: A tinted surface with a tinted border.

1, the default

Body text. Muted text.

New Overdue

Info: A tinted surface with a tinted border.

More

Body text. Muted text, closer to the body text.

New Overdue

Info: A tinted surface with a tinted border.

``` #### Inverse band ```html

Selected work

Plain HTML that looks finished.

A caption in muted text, still 4.5:1.

Read the case study

``` ## Prebuilt themes Page: https://domestic-ui.odonckers.dev/principles/themes.html 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 ``` 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

Orders

As it appears on the invoice.

Draft New Paid Overdue

Items

Items in order 1042
ItemQtyTotal
Brass gears12€ 480.00
Punched cards500€ 760.00

History

Placed 12 March, shipped 14 March.

Analytical Engines Ltd.

Customer since 2019 · 14 orders.

Delete order 1042?

This cannot be undone.

``` #### Calm, soft and compact ```html

Calm theme

Release notes are ready for review. Read the summary before the meeting.

Draft New Passing Review Blocked

Release notes go to this address.

Error: enter an email address like name@example.com.

Warning: Two checks are still running.

Notes

Two bug fixes and a new token.

Checks

Lint passed. Tests are running.

What changed?

Two bug fixes and a new --dui-color-success token.

Soft theme

Release notes are ready for review. Read the summary before the meeting.

Draft New Passing Review Blocked

Release notes go to this address.

Error: enter an email address like name@example.com.

Warning: Two checks are still running.

Notes

Two bug fixes and a new token.

Checks

Lint passed. Tests are running.

What changed?

Two bug fixes and a new --dui-color-success token.

Neutral theme

Release notes are ready for review. Read the summary before the meeting.

Draft New Passing Review Blocked

Release notes go to this address.

Error: enter an email address like name@example.com.

Warning: Two checks are still running.

Notes

Two bug fixes and a new token.

Checks

Lint passed. Tests are running.

What changed?

Two bug fixes and a new --dui-color-success token.

Compact theme

Release notes are ready for review. Read the summary before the meeting.

Draft New Passing Review Blocked

Release notes go to this address.

Error: enter an email address like name@example.com.

Warning: Two checks are still running.

Notes

Two bug fixes and a new token.

Checks

Lint passed. Tests are running.

What changed?

Two bug fixes and a new --dui-color-success token.

``` ### 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` | ## Motion Page: https://domestic-ui.odonckers.dev/principles/motion.html Motion is CSS-first, token-driven and close to platform behavior: short fades, a drawer that slides from its edge, popovers and menus that grow a little as they appear, and color changes on buttons, links and the switch. Nothing waits on a transition to work. - **Transitions only, no keyframe animations.** Every component uses [`transition`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition). Dialogs, drawers and popovers animate in and out of the top layer with [`@starting-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style) and [`transition-behavior: allow-discrete`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior) ([CSS Transitions 2](https://drafts.csswg.org/css-transitions-2/#transition-behavior-property)). An engine without them opens and closes the element with no transition. - **Tokens drive every duration and easing.** `--dui-motion-duration-fast`, `-normal` and `-slow` are primitives times `--dui-motion-scale` (default `1`), so one value on `:root` makes all motion slower (`2`) or off (`0`). Easings: `--dui-motion-easing-standard` for state changes, `--dui-motion-easing-enter` for things arriving, `--dui-motion-easing-exit` for things leaving, and `--dui-motion-easing-spring` for popover, menu and drawer entrances: a critically damped spring written with [`linear()`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/easing-function/linear), set only inside `@supports`, so an engine without `linear()` keeps the enter curve. - **Movement is a separate knob.** `--dui-motion-movement` is `1` by default. Distances (`--dui-motion-distance`, `--dui-motion-zoom`, `--dui-motion-press-scale`, the drawer's off-screen offset) and the duration of every [`translate`](https://developer.mozilla.org/en-US/docs/Web/CSS/translate) or [`scale`](https://developer.mozilla.org/en-US/docs/Web/CSS/scale) transition are multiplied by it. - **Reduced motion keeps fades and drops movement.** Under [`prefers-reduced-motion: reduce`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) ([Media Queries 5](https://www.w3.org/TR/mediaqueries-5/#prefers-reduced-motion)) movement becomes `0`: the drawer fades in place, popovers fade without growing, the switch thumb jumps while its color still fades. This is what [2.3.3 Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html) asks for. It says that motion animation triggered by interaction can be disabled. **Our choice:** keep opacity and color transitions under reduced motion, because a fade is not motion animation and it still shows where a change came from. - **`data-motion` on any element.** `data-motion="reduced"` behaves exactly like the media query for everything inside. `data-motion="none"` sets `--dui-motion-enabled` to `0`, so every duration is `0s` even where a `--dui-motion-scale` is set inside it. An empty `data-motion` is a scope for your own `--dui-motion-*` overrides: motion tokens are re-declared on it, as theme tokens are on `[data-theme]` ([CSS Variables](https://www.w3.org/TR/css-variables-1/#cycles)). **Our choice:** no `data-motion="full"`, so a page can never override a user's reduced-motion setting. - **Essential feedback never animates.** Focus indicators, validation errors and `aria-invalid`, alert and live-region text, and loading state (`aria-busy`) change at once. **Our choice:** text fields do not animate their border at all, because the same border shows the invalid state. - **View transitions are progressive enhancement only.** domestic-ui starts none and nothing depends on one. When your script calls `document.startViewTransition()` ([View Transition API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API), [CSS View Transitions](https://drafts.csswg.org/css-view-transitions-1/)), the base layer gives its pseudo-elements the motion tokens inside `@supports`, so they follow the scale and reduced motion too. | Transition | Components | Duration | Moves | | --- | --- | --- | --- | | Fade and lift | Dialog, toast | `--dui-motion-duration-normal` | `translate` by `--dui-motion-distance` | | Slide and fade | Drawer | `--dui-motion-duration-slow`, spring | `translate` by 100% of its width | | Scale and fade | Popover, menu | `--dui-motion-duration-fast`, spring | `scale` from `--dui-motion-zoom` | | Color | Buttons, links, switch track | `--dui-motion-duration-fast` | No | | Press | Buttons (`:active`) | `--dui-motion-duration-fast` | `scale` to `--dui-motion-press-scale` (0.98) | | Thumb slide | Switch | `--dui-motion-duration-fast` | `translate` | **Our choice:** 120, 200 and 300ms, longer for larger surfaces, with a decelerating (or spring) enter and an accelerating exit, because short transitions keep the UI responsive and the curves match how things arrive and leave. [`examples/motion.html`](https://domestic-ui.odonckers.dev/principles/motion.md) shows each transition, the scale, and reduced and no-motion scopes side by side. ### Page transitions (opt-in) `css/domestic.css` does not turn on page transitions. A site that wants them adds the "Page transitions CSS" snippet below to its own stylesheet: [`@view-transition { navigation: auto }`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@view-transition) makes same-origin navigations cross-fade ([CSS View Transitions Level 2](https://www.w3.org/TR/css-view-transitions-2/)), a unique `view-transition-name` keeps persistent chrome such as the header in place, and the motion tokens set the duration and easing, so `data-motion="none"` on the root element makes it instant. Under `prefers-reduced-motion: reduce` it is off ([2.3.3 Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html)). Browsers without support navigate as before, with no script. These docs use it: the app bar and the Docs sidebar stay while main cross-fades. Smashing Magazine lists it among [front-end features for designers](https://smashingmagazine.com/2024/12/new-front-end-features-for-designers-in-2025), for comparison. ### Live example #### Fade: dialog ```html

Fade in, fade out

Enters with --dui-motion-easing-enter and leaves with --dui-motion-easing-exit.

``` #### Page transitions CSS In the `` of the live example above. ```html ``` #### Slide: drawer ```html

Drawer

The off-screen offset is 100% times --dui-motion-movement.

``` #### Scale: popover and menu ```html

Grows and fades in.

``` #### Color and state ```html
A link
``` #### Toast ```html ``` #### Motion scale ```html

Three times the normal duration.

``` #### Reduced and no motion ```html

data-motion="reduced"

Fades without growing.

Reduced motion

Fades in place instead of sliding.

data-motion="none"

Appears at once.

No motion

Appears at once.

``` #### View transition ```html
  1. Draft
  2. Review
  3. Publish

``` ## Elevation Page: https://domestic-ui.odonckers.dev/principles/elevation.html Elevation says which layer is on top. Five levels, each a [`box-shadow`](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) paired with a surface color: | Level | Role token | Used by | | --- | --- | --- | | `--dui-elevation-0` | `--dui-elevation-flat` | The page and content on it | | `--dui-elevation-1` | `--dui-elevation-raised` | Cards | | `--dui-elevation-2` | `--dui-elevation-overlay` | Toasts | | `--dui-elevation-3` | `--dui-elevation-popover` | Popovers, menus, tooltips, nav dropdowns | | `--dui-elevation-4` | `--dui-elevation-dialog` | Dialogs and drawers | | `--dui-elevation-1` | `--dui-elevation-panel` | The app shell's main content panel on the frame, on `--dui-elevation-panel-surface` (the page surface) | Each has a `-surface` twin (`--dui-elevation-2-surface`, `--dui-elevation-overlay-surface`). **Components use the role tokens only**, never the numbers, so a theme can move a role to another level. - **A ring plus soft layers.** Every level from 1 up is a 1px ring in the hairline color (`--dui-elevation-ring`) plus one or two layers with a negative spread, at 12% alpha or less in light: level 1 is `0 1px 2px -1px`; level 2 `0 2px 4px -2px` and `0 4px 12px -4px`; level 3 `0 4px 8px -4px` and `0 12px 24px -8px`; level 4 `0 8px 16px -8px` and `0 24px 48px -12px`. The ring is part of the role, so **an elevated component draws no border of its own**. It keeps a transparent border for forced colors (below). Radix Themes builds its shadows the same way ([shadows](https://www.radix-ui.com/themes/docs/theme/shadows)), for comparison. - **Light scheme: the shadow does the work.** Every level keeps `--dui-color-surface`. Shadows grow with the level. - **Dark scheme: lighter surfaces.** Shadows barely show on a dark page, so each level mixes `--dui-elevation-surface-step` more of the text color into the surface with [`color-mix()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix) ([CSS Color 5](https://www.w3.org/TR/css-color-5/#color-mix)), picked per scheme by [`light-dark()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark). Levels 2 to 4 add a 1px top inset highlight (`--dui-elevation-highlight`) in dark only, and the ring reads slightly brighter because the dark hairline is the light text color at low alpha. Text, muted text, links, control borders and the focus ring meet [4.5:1](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html) and [3:1](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) on every level, in light and dark, in the default and forest themes. `tests/tokens.spec.js` checks it. - **Theme knobs.** `--dui-color-shadow` (shadow color), `--dui-elevation-strength` (0% to 100% of it) and `--dui-elevation-surface-step` (dark-scheme step per level). The levels are re-derived on every theme scope, like the other dependent tokens. - **Forced colors: borders, not shadows.** In [forced colors mode](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors) `box-shadow` computes to `none` ([CSS Color Adjustment](https://www.w3.org/TR/css-color-adjust-1/#forced-colors-properties)), so every elevated component keeps a transparent border, which forced colors paints in a system color (`CanvasText`) there. - **Floating panels.** `--dui-elevation-panel` and `--dui-elevation-panel-surface`, with `--dui-radius-surface` corners and `--dui-space-panel-inset` from the frame edge, are for the app shell's main content panel. The app bar and the sidebars sit flat on `--dui-color-surface-frame` around it, with no hairlines. **Our choice:** one inset content panel on a quiet frame, as [Linear](https://linear.app/blog/how-we-redesigned-the-linear-ui) draws its app, because a single edge separates the chrome from the content with less noise than floating every sidebar. - **Our choice:** toasts sit at the overlay level, below popovers and dialogs, because they are non-modal and must not cover an open menu or dialog. - **Our choice:** the dark-scheme step mixes in the text color rather than white, so a theme's tint carries into its raised surfaces. `--dui-shadow-raised` is deprecated: it now points at `--dui-elevation-1` and is removed in the next release. [`examples/elevation.html`](https://domestic-ui.odonckers.dev/principles/elevation.md) shows every level in light and dark side by side. ### Live example #### Levels in light and dark ```html

Light

  1. Level 0: flat The page itself and content on it. Link
  2. Level 1: raised Cards. Link
  3. Level 2: overlay Toasts and other non-modal layers. Link
  4. Level 3: popover Popovers, menus, tooltips, nav dropdowns. Link
  5. Level 4: dialog Dialogs and drawers. Link
  6. Role: panel Floating sidebars and side panels: the level 2 shadow on the raised surface. Link

Dark

  1. Level 0: flat The page itself and content on it. Link
  2. Level 1: raised Cards. Link
  3. Level 2: overlay Toasts and other non-modal layers. Link
  4. Level 3: popover Popovers, menus, tooltips, nav dropdowns. Link
  5. Level 4: dialog Dialogs and drawers. Link
  6. Role: panel Floating sidebars and side panels: the level 2 shadow on the raised surface. Link
``` #### Level swatch CSS Each `.level` swatch draws one elevation level from two custom properties: `--level-shadow` (its `box-shadow`) and `--level-surface` (its background). In the `` of the live example above. ```html ``` #### Components by role ```html

Level 3, the popover level.

Level 4: dialog

The highest level, with the lightest surface in the dark scheme.

``` ## Opinions we hold Page: https://domestic-ui.odonckers.dev/principles/opinions-we-hold.html Each of these is a choice between valid options, not a standard. - **Our choice:** [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values) (`margin-block`, `inline-size`), so right-to-left and vertical writing modes work unchanged. - **Our choice:** keep link underlines, because color alone is not enough to spot a link (WCAG 1.4.1). - **Our choice:** system font stacks from [Modern Font Stacks](https://modernfontstacks.com/), because they cost no network requests and match the platform. `css/domestic.css` makes no font request. For a consistent face across platforms (and pinned screenshots), the optional `css/fonts/inter.css` declares a self-hosted [Inter](https://rsms.me/inter/) 4 variable font (Latin and Latin Extended subsets split by [`unicode-range`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@font-face/unicode-range), [`font-display: swap`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@font-face/font-display), an optical size axis that [`font-optical-sizing`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font-optical-sizing) uses automatically, [SIL OFL 1.1](https://openfontlicense.org/)). Opt in by linking it and setting `--dui-font-body: Inter, system-ui, sans-serif`. The docs site does. - **Our choice:** a productive and an expressive type scale (as [Carbon](https://carbondesignsystem.com/elements/typography/overview/) splits them, for comparison): steps up to `--dui-step-2` are fixed, and `--dui-step-3` to `-5` are fluid with [`clamp()`](https://developer.mozilla.org/en-US/docs/Web/CSS/clamp) in `rem`, so display text grows with the viewport and everything respects the user's font size ([1.4.4 Resize Text](https://www.w3.org/WAI/WCAG22/Understanding/resize-text.html)). - **Our choice:** interface text (buttons, fields, nav, menus, tabs, badges, tooltips, table cells) is 14px (`--dui-font-size-ui`), as in Primer, Fluent 2, Radix Themes and shadcn/ui, for comparison. Prose stays 16px. An app page title (`--dui-font-size-page-title`) is step 4, 38px at most, one step above h2. Step 5 is for docs and marketing heroes. - **Our choice:** text fields, selects and text areas use `--dui-font-size-field`: the UI size on a fine pointer and at least 16px under a coarse one ([`pointer`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/pointer), [`max()`](https://developer.mozilla.org/en-US/docs/Web/CSS/max)), because iOS Safari zooms the page into a focused field with smaller text. The 44px coarse-pointer field height already fits it. The viewport meta never limits zoom ([1.4.4 Resize Text](https://www.w3.org/WAI/WCAG22/Understanding/resize-text.html)). - **Our choice:** a 60ch measure for prose, near the commonly cited 45 to 75 characters per line ([WCAG 1.4.8 Visual Presentation](https://www.w3.org/WAI/WCAG22/Understanding/visual-presentation.html) asks for 80 or fewer). - **Our choice:** rhythm from the "lobotomized owl" selector (`* + *`) inside flow containers ([Heydon Pickering](https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/)), wrapped in `:where()` so it has zero specificity. - **Our choice:** `type="submit"` buttons get the primary fill and other buttons stay neutral, so the primary action is marked by its native type, with no class. - **Our choice:** checkboxes, radios and range keep native rendering tinted with [`accent-color`](https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color), because native controls keep their platform accessibility. - **Our choice:** each atom has one `data-` attribute whose value is a space-separated list (`data-button="primary small"`), matched with `~=`, instead of modifier classes. The other atom choices (button variants, focus rings, switch, field errors, badge tints) are listed with their reasons in the [atoms index](https://github.com/odonckers/domestic-ui/blob/main/css/components/atoms/README.md#our-choices). - **Our choice:** molecules follow the same rule (`data-card="link"`, `data-dialog="drawer end"`), or use the native element or ARIA role when that already says everything (``, `role="toolbar"`). The molecule choices are listed with their reasons in the [molecules index](https://github.com/odonckers/domestic-ui/blob/main/css/components/molecules/README.md#our-choices). The main ones: - **Our choice:** tabs select on focus (automatic activation), as the [APG recommends](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/#deciding-when-to-make-selection-automatically-follow-focus) when panels show at once. `activation="manual"` is available. - **Our choice:** the drawer is a `` variant, so the browser handles modality, focus and Esc ([explainer](https://domestic-ui.odonckers.dev/explainers/drawer.md)). - **Our choice:** a clickable card links its heading and stretches that link over the card, so the accessible name stays the heading ([explainer](https://domestic-ui.odonckers.dev/explainers/card.md)). - **Our choice:** toasts never dismiss themselves and never take focus ([explainer](https://domestic-ui.odonckers.dev/explainers/toast.md)). - **Our choice:** the typeahead (``) upgrades a native `` + ``, not a `
``` ### API | Attribute or value | Where | Effect | | --- | --- | --- | | `data-action-bar` | a `