domestic-ui GitHub

Theming

Two tiers of tokens

All tokens are custom properties on :root with the --dui- prefix.

TierFileNamed byExamplePublic?
Primitivecss/tokens/primitives.cssWhat it is--dui-color-indigo-9: oklch(53% 0.215 272); --dui-space-5: 1rem;No. Internal, may change in any release.
Semanticcss/tokens/semantic.cssWhat it is for--dui-color-accent: light-dark(var(--dui-color-neutral-12), var(--dui-color-neutral-dark-12));Yes. The stable theming API.

Base, layout, utility and component CSS reference only semantic tokens. They never use primitives and never hard-code colors or sizes (0, 1px hairlines, percentages, fr, currentcolor, inherit, transparent and system colors are fine). npm test enforces this with scripts/check-tokens.mjs (npm run lint:tokens), which also rejects literal colors in semantic.css.

Our choice: the --dui- prefix, so tokens never collide with your own custom properties.

Color

Color primitives are oklch() in OKLCH (CSS Color 4), inside the sRGB gamut. Neutral and indigo each have 12 steps in light and in dark. The step number is the role:

StepRole
1Page
2Raised
3Sunken or element
4Hover
5Active or selected
6Subtle border
7Border
8Control border
9Solid
10Solid hover
11Muted or accent text
12Text

On a Display P3 screen (@media (color-gamut: p3)) the accent solids (indigo 9 and 10) and the status solids (step 9) take more chroma at the same lightness and hue: the sRGB chroma times how much further P3 reaches there, so they are as saturated relative to P3 as they are to sRGB, and stay inside it (gamut mapping). Contrast pairs keep their ratios, and npm test checks them with P3 emulated. Text steps (11 and 12) and neutrals do not change. Geist also uses P3 where supported, for comparison.

Red, green, amber and blue have steps 3, 9 and 11. Radix Colors numbers a scale the same way. Tailwind v4 and Geist also ship OKLCH ramps. Those are other systems, for comparison.

Our choice: the default is warm paper. Neutrals are ivory on the pale steps and brown ink on step 12 (hue 85 toward 45, chroma 0.035 at most), and step 2 (raised) is lighter than step 1 (the page), so cards and panels sit on the page like brighter paper. --dui-color-primary is neutral step 12, the ink (brown on a light page, ivory on a dark one), and --dui-color-primary-contrast is the paper on that fill. --dui-color-primary-hover is a relative color of the primary (MDN), so it keeps the primary's hue. Primary buttons and type="submit" read these three. The accent is clay, oklch(57% 0.17 42), the same in both schemes: links (as the accent text), focus, checks, switches and selection. Titles (h1 to h3) use the transitional serif stack (--dui-font-display), and a dotted grid (--dui-pattern-image) sits on the page and an app shell's frame. The earlier achromatic look, closer to shadcn/ui's neutral theme, is the opt-in neutral theme. --dui-color-accent-indigo keeps an indigo solid for themes such as calm.

--dui-color-accent-text is a relative color of --dui-color-accent: the same hue, with lightness and chroma set for 1.4.3 Contrast (Minimum). --dui-color-link points at it. --dui-color-focus is the accent solid in light and the accent text in dark, so the ring meets 1.4.11 Non-text Contrast on a dark page. Our choice: an achromatic accent (chroma 0, fading in up to 0.02) instead gives the text color for --dui-color-accent-text and a mid gray at 3:1 for the focus ring, so the neutral default looks like shadcn/ui's while a hued accent behaves as before. The ring is 3px and hugs the edge, like shadcn/ui's, but opaque rather than a translucent halo, so it keeps 3:1. --dui-color-accent-hover and --dui-color-accent-surface are derived from the accent too, so a theme that sets only --dui-color-accent still gets a matching link, hover and tint. --dui-color-accent-contrast is white, except on the neutral dark accent, where it is the dark page color.

--dui-color-border is the ink at about 14% alpha, a warm hairline. --dui-color-border-control stays an opaque step at 3:1 for fields, selects, checkboxes, radios and switches, whose boundary is what shows where to click or type. Our choice: the secondary button's border, --dui-color-border-button, is a softer step, because its visible text label identifies it and 1.4.11 asks for 3:1 only for the visual information needed to identify a component. --dui-color-shadow is a warm brown at low alpha.

Light and dark values use light-dark() (CSS Color 5). tests/contrast.js checks the pairs below, and the status and code colors, against these thresholds. It takes a theme scope, so another theme can reuse it.

A theme is a semantic-token override

No build step. Override semantic tokens on :root for the whole page, or on any element with a data-theme attribute or a theme-* class to scope it:

[data-theme="forest"] {
  --dui-color-surface: light-dark(#f7f5ef, #141a16);
  --dui-color-text: light-dark(#1d2a22, #e4ebe3);
  --dui-color-accent: light-dark(#2f6b3f, #7fcf95);
  --dui-color-accent-contrast: light-dark(#fff, #0f1a13);
  --dui-color-primary: light-dark(#173528, #d7f5e3);
  --dui-color-primary-contrast: light-dark(#fff, #0f1a13);
}
<section data-theme="forest">…</section>

examples/theming.html shows a full scoped theme next to the default.

A theme has three inputs: the neutrals (surface and text), the accent, and contrast. Linear builds its themes from the same trio (how they redesigned the UI), for comparison. --dui-contrast (default 1) is the contrast input. Above 1, --dui-color-text-muted moves toward --dui-color-text with color-mix() (halfway at 1.5), the alpha of --dui-color-border scales through a relative color, and --dui-tint-amount and --dui-border-tint-amount scale, so tinted surfaces and borders stand out more. prefers-contrast: more sets it to 1.5, and so does data-contrast="more" on any element for its subtree. An empty data-contrast scopes your own value. Forced colors are handled separately. Our choice: below 1 only hairlines and tints soften and muted text never moves, and there is no "less" value, so text stays at 4.5:1 (1.4.3) and control boundaries at 3:1 (1.4.11) at every setting. npm test checks the pairs at 0.8, 1 and 1.5. A theme that sets --dui-color-text-muted or --dui-color-border itself (the soft theme does) takes those values as they are. Shape has one knob: --dui-radius-scale multiplies --dui-radius-control (8px) and --dui-radius-surface (12px). 0 gives square corners and 1.5 rounder ones, while pills stay round. Radix Themes has the same idea (--radius-factor), for comparison.

Nested corners are concentric: an item inside a rounded container takes the container's radius less the padding between them, never below 0, so the two curves share a centre. --dui-radius-nested is max(0px, calc(--dui-radius-surface - --dui-space-gap-tight)), used by menu items, listbox options and the links in a horizontal nav dropdown (border-radius, calc(), max()). It follows --dui-radius-scale and density, and at scale 0 it is square. Apple's 2025 design language and Vercel's Web Interface Guidelines ask for the same, for comparison. Our choice: nav rows in a sidebar, code blocks in cards and the floating panels keep their own radii, because their padding is as large as the outer radius or larger, so the concentric value would be square. Type has one opt-in: link css/fonts/inter.css and set --dui-font-body: Inter, system-ui, sans-serif to use the self-hosted Inter instead of the system stack (see "Opinions we hold"). Nothing else changes. Check your theme's contrast in both schemes. tests/tokens.spec.js shows how.

Prebuilt themes

Four opt-in themes ship in css/themes/. css/domestic.css imports none of them, so the default ships no extra bytes. Link one after css/domestic.css and put its name in data-theme on :root or any element (examples/themes.html). Each file sets semantic tokens only (npm run lint:tokens checks it), with light and dark values, so scopes nest, and forced colors keep the base behavior.

Themedata-themeTokens it changes
Calmcalm--dui-color-accent is --dui-color-accent-indigo, and --dui-color-primary, -primary-hover and -primary-contrast follow it (white text), so links and focus are indigo too; --dui-color-shadow tinted with the accent hue. Radius and density stay the default.
SoftsoftWarm neutrals (hue 70, chroma 0.02 at most) for every surface, text and border token; --dui-color-accent terracotta oklch(55% 0.15 40) as the primary with white text; --dui-radius-scale 1.5 (12 / 18px); --dui-density-scale 1.25 (roomier padding); --dui-elevation-strength 80% and a warm --dui-color-shadow.
Compactcompact--dui-color-accent blue oklch(53% 0.15 250); --dui-radius-scale 0.25 (2 / 3px); --dui-density-scale 0 (32px controls, 44px under a coarse pointer); --dui-elevation-strength 35%, so hairlines carry the edges.
NeutralneutralThe achromatic look that was the default before ivory: white page (chroma 0) and near-black text for every surface, text and border token; --dui-color-accent and --dui-color-primary are the text color, so links read as underlined text; --dui-color-surface-frame raised; cards and the content panel on the page color; sans titles (--dui-font-display is --dui-font-heading); no page pattern (--dui-pattern-image: none). Muted text and hairlines still follow --dui-contrast.

To write your own, copy one of these files: keep the @layer statement and the @layer tokens block, set only semantic tokens, give each color a light and a dark value, and add your scope to registerContrastTests in tests/tokens.spec.js. Our choice: each file repeats the layer order and puts its overrides in the tokens layer, so it works linked before or after css/domestic.css and your unlayered CSS still wins. Themes never change type sizes. Density changes spacing and targets only. Radix Themes, shadcn/ui and Carbon ship themes the same way, as token sets, for comparison.

A few semantic tokens are defined in terms of others (--dui-color-accent-text, --dui-color-link, --dui-color-focus, --dui-color-accent-hover and --dui-color-accent-surface follow --dui-color-accent; --dui-color-primary-hover follows --dui-color-primary; the badge tints --dui-color-*-surface mix a tone into --dui-color-surface). A custom property's var() is resolved on the element that declares it (CSS Variables, "Resolving dependency cycles"), so these, plus color, background-color and font-family, are re-applied on every [data-theme], .theme-* and [data-color-scheme] element. Our choice: data-theme (or a theme-* class) as the single scoping API, so one attribute makes an element a theme root. An override on any other selector (say .sidebar) still reaches properties that read the token directly on an element (borders, buttons, links, headings, controls), but not inherited text color, background or derived tokens. Add data-theme to that element to get the full effect.

Semantic tokens (public API)

Renaming or removing a semantic token is a breaking change (see Versioning). Primitives are internal and may change. Fluid --dui-step-* values are clamp() expressions. See primitives.css.

TokenPurposeDefault (primitive, light / dark)
--dui-color-surfacePage and control background: ivory paper (neutral step 1)light: neutral-1 (oklch(96.6% 0.012 85))
dark: neutral-dark-1 (oklch(18.5% 0.012 55))
--dui-color-surface-raisedBrighter paper on the page: cards, panels, table row hover (step 2)light: neutral-2 (oklch(98.8% 0.006 85))
dark: neutral-dark-2 (oklch(21.5% 0.014 55))
--dui-color-surface-sunkenRecessed areas: code, button hover (step 3)light: neutral-3 (oklch(93.8% 0.014 82))
dark: neutral-dark-3 (oklch(22% 0.015 55))
--dui-color-surface-hoverHover fill of quiet buttons, nav, menu and listbox rows (step 4)light: neutral-4 (oklch(92.4% 0.016 80))
dark: neutral-dark-4 (oklch(27% 0.016 55))
--dui-color-surface-activePressed fill of quiet buttons (step 5)light: neutral-5 (oklch(89.8% 0.018 78))
dark: neutral-dark-5 (oklch(31% 0.018 55))
--dui-color-surface-frameBackground of an app shell's frame: the app bar and sidebars sit on it, around the main content panel--dui-color-surface
--dui-color-textBody text: the ink (step 12)light: neutral-12 (oklch(28% 0.035 45))
dark: neutral-dark-12 (oklch(95% 0.012 85))
--dui-color-text-mutedSecondary text, captions, list markers (step 11, still 4.5:1). Above --dui-contrast 1 it moves toward --dui-color-textlight: neutral-11 (oklch(49% 0.03 55))
dark: neutral-dark-11 (oklch(75% 0.02 70))
--dui-color-borderDecorative hairline: the ink at about 14% alpha, times --dui-contrastlight: neutral-12 at 14% (oklch(28% 0.035 45 / 14%))
dark: neutral-dark-12 at 12% (oklch(95% 0.012 85 / 12%))
--dui-color-border-controlBoundaries of fields, selects, checkboxes, radios and switches (step 8, 3:1)light: neutral-8 (oklch(57% 0.03 60))
dark: neutral-dark-8 (oklch(57% 0.025 60))
--dui-color-border-control-hoverField border on hover (step 9)light: neutral-9 (oklch(50% 0.03 55))
dark: neutral-dark-9 (oklch(66% 0.022 65))
--dui-color-border-buttonSecondary button border (step 6): softer, because the visible label identifies the buttonlight: neutral-6 (oklch(86% 0.02 75))
dark: neutral-dark-6 (oklch(35% 0.02 55))
--dui-color-primaryPrimary action fill: the ink (neutral step 12)light: neutral-12 (oklch(28% 0.035 45))
dark: neutral-dark-12 (oklch(95% 0.012 85))
--dui-color-primary-contrastText on the primary fill: paper on inklight: neutral-2 (oklch(98.8% 0.006 85))
dark: neutral-dark-1 (oklch(18.5% 0.012 55))
--dui-color-accentAccent solid for selection, checks, switches and focus, and the hue of links: clayclay-9 (oklch(57% 0.17 42))
--dui-color-accent-indigoAn indigo accent solid, more vivid on a Display P3 screen; the calm theme's accentlight: indigo-9 (oklch(53% 0.215 272))
dark: indigo-dark-9 (oklch(53% 0.215 272))
--dui-color-accent-contrastText on the accent fill, white in both schemeswhite (oklch(100% 0 0))
--dui-color-link-visitedVisited linkslight: purple-11 (oklch(46.2% 0.195 299))
dark: purple-dark-11 (oklch(80.1% 0.127 306))
--dui-color-dangerErrors, :user-invalid borders (red step 11)light: red-11 (oklch(48% 0.16 27))
dark: red-dark-11 (oklch(80% 0.114 27))
--dui-color-successSuccess messages (green step 11)light: green-11 (oklch(47% 0.128 150))
dark: green-dark-11 (oklch(80% 0.12 150))
--dui-color-warningWarning badges and messages (amber step 11)light: amber-11 (oklch(47% 0.098 75))
dark: amber-dark-11 (oklch(80% 0.12 75))
--dui-color-infoInformational alerts and toasts (blue step 11, separate from the accent, so a brand color never reads as a status)light: blue-11 (oklch(48% 0.12 245))
dark: blue-dark-11 (oklch(80% 0.108 245))
--dui-color-markmark and ::selection backgroundlight: yellow-3 (oklch(95.3% 0.093 99))
dark: yellow-dark-9 (oklch(83.4% 0.141 97))
--dui-color-mark-textText on markneutral-12 (oklch(28% 0.035 45))
--dui-color-backdropdialog::backdroplight: black-a40 (oklch(0% 0 0 / 40%))
dark: black-a60 (oklch(0% 0 0 / 60%))
--dui-color-shadowShadow color: warm brown at low alphalight: neutral-shadow (oklch(30% 0.04 45 / 10%))
dark: neutral-dark-shadow (oklch(10% 0.02 45 / 50%))
--dui-color-code-keywordJS keywords and CSS at-rules in highlighted code (4.5:1 on surface-sunken)light: purple-11 (oklch(46.2% 0.195 299))
dark: purple-dark-11 (oklch(80.1% 0.127 306))
--dui-color-code-stringStrings and HTML attribute values in highlighted code (4.5:1 on surface-sunken)light: green-11 (oklch(47% 0.128 150))
dark: green-dark-11 (oklch(80% 0.12 150))
--dui-color-code-commentComments in highlighted code (4.5:1 on surface-sunken)light: neutral-11 (oklch(49% 0.03 55))
dark: neutral-dark-11 (oklch(75% 0.02 70))
--dui-color-code-tagHTML tag names and CSS selectors in highlighted code (4.5:1 on surface-sunken)light: blue-11 (oklch(48% 0.12 245))
dark: blue-dark-11 (oklch(80% 0.108 245))
--dui-color-code-attributeHTML attribute names in highlighted code (4.5:1 on surface-sunken)light: amber-11 (oklch(47% 0.098 75))
dark: amber-dark-11 (oklch(80% 0.12 75))
--dui-color-code-propertyCSS and JS properties in highlighted code (4.5:1 on surface-sunken)light: teal-11 (oklch(49.1% 0.081 203))
dark: teal-dark-11 (oklch(77.3% 0.099 203))
--dui-color-code-numberNumbers and units in highlighted code (4.5:1 on surface-sunken)light: red-11 (oklch(48% 0.16 27))
dark: red-dark-11 (oklch(80% 0.114 27))
--dui-color-code-punctuationBrackets, braces and separators in highlighted code (4.5:1 on surface-sunken)light: neutral-punctuation (oklch(37% 0.03 45))
dark: neutral-dark-punctuation (oklch(84% 0.015 75))
--dui-font-bodyBody font stack--dui-font-stack-system-ui (system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif)
--dui-font-monoCode font stack--dui-font-stack-monospace (ui-monospace, …, monospace)
--dui-font-weight-bodyBody weightfont-weight-400 (400)
--dui-font-weight-strongstrong, legends, thfont-weight-600 (600)
--dui-font-weight-uiInterface labels: buttons, nav rows and field labelsfont-weight-500 (500)
--dui-font-weight-headingh1–h6font-weight-600 (600)
--dui-step--1small, captions, and the UI text sizefont-size-0-875 (0.875rem, 14px)
--dui-step-0Body text, h6font-size-1 (1rem)
--dui-step-1h5font-size-1-125 (1.125rem)
--dui-step-2h4font-size-1-375 (1.375rem)
--dui-step-3h3, page titlesfont-size-fluid-3 (clamp(), 1.5rem to 1.875rem)
--dui-step-4h2font-size-fluid-4 (clamp(), 1.75rem to 2.375rem)
--dui-step-5h1, docs and marketing heroesfont-size-fluid-5 (clamp(), 2rem to 3rem)
--dui-font-size-uiInterface text: buttons, fields, selects, nav, menu and listbox items, tabs, tooltips, table cells--dui-step--1 (14px)
--dui-font-size-fieldText in fields, selects and text areas: the UI size, at least 16px under a coarse pointer--dui-font-size-ui; max(--dui-font-size-ui, --dui-step-0) under pointer: coarse
--dui-font-size-badgeBadge text, as shadcn/ui sets its badgefont-size-0-75 (0.75rem, 12px)
--dui-font-size-page-titleThe h1 of a page header or an app shell--dui-step-4 (2.375rem at most, one step above h2)
--dui-font-size-codecode, kbd, samp, pre (relative)font-size-relative-90 (0.9em)
--dui-line-height-bodyBody textleading-150 (1.5)
--dui-line-height-headingHeadings, buttons, preleading-120 (1.2)
--dui-line-height-displayh1leading-110 (1.1)
--dui-letter-spacing-headingh2, h3tracking-tight (-0.02em)
--dui-letter-spacing-displayh1tracking-tighter (-0.03em)
--dui-measureMax line length for prosesize-60ch (60ch)
--dui-space-3xsSpace scalespace-1 (0.125rem)
--dui-space-2xsSpace scalespace-2 (0.25rem)
--dui-space-xsSpace scalespace-3 (0.5rem)
--dui-space-sSpace scalespace-4 (0.75rem)
--dui-space-mSpace scale; default flow rhythm and .stack gapspace-5 (1rem)
--dui-space-lSpace scale; default .grid gapspace-6 (1.5rem)
--dui-space-xlSpace scale; space above h1–h3space-7 (2rem)
--dui-space-2xlSpace scalespace-8 (3rem)
--dui-space-3xlSpace scalespace-9 (4rem)
--dui-size-targetComfortable control height (WCAG 2.5.8 needs 24px; this gives 36px)size-2-25 (2.25rem); size-2-75 (2.75rem) under pointer: coarse
--dui-size-target-compactCompact control heightsize-2 (2rem); size-2-75 under pointer: coarse
--dui-size-target-smallSmall buttons (32px, 44px under a coarse pointer)size-2 (2rem)
--dui-size-target-largeLarge buttonssize-2-5 (2.5rem); size-3-25 (3.25rem) under pointer: coarse
--dui-size-target-rowComfortable row height of nav, menu, listbox and list itemssize-2 (2rem); size-2-75 under pointer: coarse
--dui-size-target-row-compactCompact row heightsize-1-75 (1.75rem); size-2-75 under pointer: coarse
--dui-size-checkCheckbox and radio sizesize-1-25 (1.25rem)
--dui-size-column-minDefault .grid min column widthsize-16 (16rem)
--dui-size-menu-minMin width of menus and nav dropdownssize-12 (12rem)
--dui-size-drawerDrawer width (all of the viewport when narrower)size-24 (24rem)
--dui-size-pageMax inline size of a page's content column (the examples' header, main and footer)size-72 (72rem)
--dui-size-iconDecorative icons beside a label: nav links and group summariessize-1-25 (1.25rem)
--dui-size-icon-inlineIcons inside buttons, menu items, options and toolbarssize-1 (1rem)
--dui-icon-stroke-widthStroke width of [data-icon] SVGs, set with the CSS stroke-width propertystroke-1-75 (1.75)
--dui-size-sidebarInline size of an app shell's primary sidebar beside mainsize-16 (16rem)
--dui-size-sidebar-auxInline size of an app shell's auxiliary (inline-end) sidebar beside mainsize-20 (20rem)
--dui-size-paneMax block size of a pane that scrolls on its own beside others (the detail of a list-detail when side by side)size-100svh (100svh, the small viewport height)
--dui-radius-scaleRadius knob: multiplies the control and surface radii; 0 gives square cornersfactor-1 (1)
--dui-radius-controlControls, buttons, inline coderadius-2 (0.5rem, 8px) × --dui-radius-scale
--dui-radius-surfacePanels, cards, pre, dialog, details, mediaradius-3 (0.75rem, 12px) × --dui-radius-scale
--dui-radius-nestedItems inside a surface padded by --dui-space-gap-tight (menu, listbox, nav dropdown): concentric corners--dui-radius-surface − --dui-space-gap-tight, at least 0 (8px at scale 1)
--dui-radius-pillFully rounded ends (not scaled)radius-round (999rem)
--dui-space-panel-insetGap between a floating panel and the viewport or frame edge--dui-space-xs (0.5rem)
--dui-border-widthHairline widthborder-1 (1px)
--dui-border-width-emphasisblockquote rule, alert start rule, invalid fieldborder-4 (0.25rem)
--dui-border-width-indicatorThe selected tab's and the current nav item's bar in forced colors onlyborder-3 (3px)
--dui-underline-offsetLink underline offsetunderline-offset-015em (0.15em)
--dui-underline-thicknessLink underlineunderline-1 (0.0625em)
--dui-underline-thickness-hoverLink underline on hoverunderline-2 (0.125em)
--dui-focus-widthFocus ring widthborder-3 (3px)
--dui-focus-offsetFocus ring offset: the ring hugs the edgeborder-0 (0)
--dui-motion-scaleMultiplies every motion durationfactor-1 (1)
--dui-motion-movementLets things slide, lift and zoom (1) or not (0); 0 with reduced motionfactor-1 (1)
--dui-motion-enabled0 with data-motion="none": every duration is 0s, whatever scale is set insidefactor-1 (1)
--dui-motion-easing-standardState changes that stay on screen: hover, press, switcheasing-ease-out (cubic-bezier(0.2, 0, 0, 1))
--dui-motion-easing-enterThings arriving: dialogs, drawers, popovers, toastseasing-decelerate (cubic-bezier(0, 0, 0, 1))
--dui-motion-easing-exitThings leavingeasing-accelerate (cubic-bezier(0.3, 0, 1, 1))
--dui-motion-easing-springPopover, menu and drawer entranceseasing-spring (a linear() spring with no overshoot); --dui-motion-easing-enter's curve where linear() is unsupported
--dui-elevation-strengthHow much of --dui-color-shadow each shadow uses (0% to 100%)mix-100 (100%)
--dui-elevation-surface-stepDark scheme: text color mixed into the surface per levelmix-3 (3%)
--dui-density-scaleDensity knob: 1 comfortable, 0 compact (data-density); in between interpolates, never below 0factor-1 (1)
--dui-opacity-disabledDisabled controls, disabled and aria-disabled="true"opacity-60 (0.6)
--dui-contrastContrast knob: 1 default, 1.5 under prefers-contrast: more or data-contrast="more"; below 1 softens hairlines and tints onlyfactor-1 (1)
--dui-tint-amountHow much of a tone goes into a tinted surfacemix-8 (8%) × --dui-contrast
--dui-border-tint-amountHow much of the text color goes into a tinted border (badges)mix-35 (35%) × --dui-contrast
--dui-color-accent-textAccent as text (links, quiet buttons, accent badges). Relative color of --dui-color-accentlight: oklch(47% 0.19 272)
dark: oklch(78% 0.11 272)
--dui-color-linkLinks--dui-color-accent-text
--dui-color-focusFocus ring (3:1 against surfaces)light: --dui-color-accent
dark: --dui-color-accent-text
--dui-color-accent-hoverAccent solid hoveroklch(from --dui-color-accent) with lightness 0.02 lower
--dui-color-primary-hoverPrimary fill hoverlight: oklch(26% 0.002 0)
dark: oklch(90% 0.004 0), hue from --dui-color-primary
--dui-font-headingHeading font stack--dui-font-body
--dui-color-accent-surfaceAccent badge backgroundcolor-mix() of --dui-tint-amount --dui-color-accent into --dui-color-surface
--dui-color-success-surfaceSuccess badge backgroundsame, with --dui-color-success
--dui-color-warning-surfaceWarning badge backgroundsame, with --dui-color-warning
--dui-color-danger-surfaceDanger badge and alert backgroundsame, with --dui-color-danger
--dui-color-info-surfaceInfo alert backgroundsame, with --dui-color-info
--dui-color-surface-inverseTooltip background--dui-color-text
--dui-color-text-inverseTooltip text--dui-color-surface
--dui-motion-duration-fastHover, press, switch, popovers and menusduration-120 (120ms) × --dui-motion-scale × --dui-motion-enabled
--dui-motion-duration-normalDialogs and toastsduration-200 (200ms) × --dui-motion-scale × --dui-motion-enabled
--dui-motion-duration-slowThe drawerduration-300 (300ms) × --dui-motion-scale × --dui-motion-enabled
--dui-motion-distanceHow far a dialog or toast lifts as it fades inspace-4 (0.75rem) × --dui-motion-movement
--dui-motion-zoomScale a popover or menu grows from0.95, or 1 when --dui-motion-movement is 0
--dui-motion-press-scaleScale of a pressed (:active) button0.98, or 1 when --dui-motion-movement is 0
--dui-elevation-shadow-colorShadow color after strengthcolor-mix() of --dui-color-shadow at --dui-elevation-strength
--dui-elevation-ringThe 1px ring in the hairline color that every elevated level includes0 0 0 1px --dui-color-border
--dui-elevation-highlightDark scheme only: a 1px top inset highlight on levels 2 to 4inset 0 1px 0 0, transparent in light, the dark text color at 6% in dark
--dui-size-controlMin block size of controls, buttons and check labels--dui-size-target (36px), --dui-size-target-compact (32px) when compact; 44px under pointer: coarse
--dui-size-rowMin block size of nav, menu, listbox, combobox option and list-detail items--dui-size-target-row (32px), --dui-size-target-row-compact (28px) when compact; 44px under pointer: coarse
--dui-space-control-blockBlock padding of controls, buttons and itemsspace-3 (0.5rem), space-2 (0.25rem) when compact
--dui-space-control-inlineInline padding of text fields and itemsspace-4 (0.75rem), space-3 (0.5rem) when compact
--dui-space-button-inlineInline padding of buttons and tabsspace-5 (1rem), space-4 (0.75rem) when compact
--dui-space-gapGap between the parts of a control (icon and label, check and label)space-3 (0.5rem), space-2 (0.25rem) when compact
--dui-space-gap-tightGap and padding in groups of controls: field, toolbar, pagination, menuspace-2 (0.25rem), space-1 (0.125rem) when compact
--dui-space-cellTable cell paddingspace-3 (0.5rem), space-2 (0.25rem) when compact
--dui-elevation-controlA 1px shadow under secondary buttons, without the ring (they have a border)0 1px 2px -1px --dui-elevation-shadow-color
--dui-elevation-0 … --dui-elevation-4Shadow per levelnone; level 1 is the ring and 0 1px 2px -1px; levels 2 to 4 add the dark highlight, the ring and two layers with a negative spread
--dui-elevation-0-surface … --dui-elevation-4-surfaceSurface per levellight: --dui-color-surface
dark: --dui-color-surface with N × --dui-elevation-surface-step of --dui-color-text
--dui-elevation-flat, -raised, -overlay, -popover, -dialogShadow by rolelevels 0, 1, 2, 3, 4
--dui-elevation-flat-surface, -raised-surface, -overlay-surface, -popover-surface, -dialog-surfaceSurface by rolelevel 0 to 4 surfaces
--dui-elevation-panelShadow of floating panels: the app shell's main content panel--dui-elevation-1
--dui-elevation-panel-surfaceSurface of floating panels--dui-color-surface
--dui-shadow-raisedDeprecated, removed in the next release: use --dui-elevation-raised--dui-elevation-1
--dui-duration-fastDeprecated, removed in the next release--dui-motion-duration-fast
--dui-duration-normalDeprecated, removed in the next release--dui-motion-duration-normal
--dui-easing-standardDeprecated, removed in the next release--dui-motion-easing-standard

Derived (re-resolved on each theme scope and on every [data-motion], [data-density] and [data-contrast] element): --dui-color-text-muted, --dui-color-border, --dui-tint-amount, --dui-border-tint-amount, --dui-color-accent-text, --dui-color-link, --dui-color-focus, --dui-color-accent-hover, --dui-color-primary-hover, --dui-font-heading, --dui-font-size-ui, --dui-font-size-field, --dui-font-size-page-title, --dui-color-accent-surface, --dui-color-success-surface, --dui-color-warning-surface, --dui-color-danger-surface, --dui-color-info-surface, --dui-color-surface-inverse, --dui-color-text-inverse, --dui-radius-control, --dui-radius-surface, --dui-radius-nested, every --dui-motion-duration-*, --dui-motion-distance, --dui-motion-zoom, --dui-motion-press-scale, every --dui-elevation-* except the two knobs, the eight density tokens (--dui-size-control, --dui-size-row and the --dui-space-control-*, -button-inline, -gap* and -cell spaces), and the deprecated aliases.

Density

data-density="compact" on any element tightens every component inside it. data-density="comfortable" is the default and restores it inside a compact area. Density changes space only: control heights (36px to 32px), row heights (32px to 28px), padding, gaps and table cells. Text size never changes, and every target stays at least 24 by 24 CSS pixels (2.5.8 Target Size (Minimum)).

  • The attribute sets one knob, --dui-density-scale (1 comfortable, 0 compact). Components read the density tokens above, each derived from the knob between its comfortable and compact value, and re-declared on every [data-density] element like the theme tokens, so nesting works both ways.
  • Comfortable values point at other semantic tokens (--dui-size-target, the space scale), so a theme that changes those moves density with it. small and large buttons keep their sizes at every density.
  • Our choice: an attribute on any ancestor, not a media query, because density follows the task (a data table, a toolbar), not the device, and one page often mixes both.
  • Our choice: no zoom or font-size scaling, because both shrink text against the user's text size and scale targets below 24px.

examples/patterns/density.html shows the same form, table and toolbar at both densities side by side. explainers/density.md has the full contract.

Live example

Forest theme

<section class="panel stack" data-theme="forest" aria-labelledby="forest-title">
  <nav aria-label="Breadcrumb, forest theme" data-breadcrumb>
    <ol>
      <li><a href="#forest-title">Home</a></li>
      <li><a href="#forest-title">Releases</a></li>
      <li><a href="#forest-title" aria-current="page">Release notes</a></li>
    </ol>
  </nav>
  <h2 id="forest-title">Forest theme</h2>
  <p>Release notes are ready for review. <a href="#forest-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="#forest-title" class="stack">
    <div data-field>
      <label for="forest-email">Email</label>
      <input id="forest-email" name="email" type="email" autocomplete="email" value="ada@" aria-invalid="true" aria-describedby="forest-email-hint forest-email-error">
      <p id="forest-email-hint" data-field-hint>Release notes go to this address.</p>
      <p id="forest-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, forest theme">
      <ul>
        <li><a href="#forest-tab-notes">Notes</a></li>
        <li><a href="#forest-tab-checks">Checks</a></li>
      </ul>
    </nav>
    <section id="forest-tab-notes">
      <h3>Notes</h3>
      <p>Two bug fixes and a new token.</p>
    </section>
    <section id="forest-tab-checks">
      <h3>Checks</h3>
      <p>Lint passed. Tests are running.</p>
    </section>
  </dui-tabs>
  <article data-card="link">
    <h3><a href="#forest-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>

Forest theme CSS

In the <head> of the live example above.

<style id="forest-theme">
  [data-theme="forest"] {
    --dui-color-surface: light-dark(#f7f5ef, #141a16);
    --dui-color-surface-raised: light-dark(#eeeadf, #1d2620);
    --dui-color-text: light-dark(#1d2a22, #e4ebe3);
    --dui-color-border: light-dark(#d8d1bf, #34433a);
    --dui-color-accent: light-dark(#2f6b3f, #7fcf95);
    --dui-color-accent-contrast: light-dark(#fff, #0f1a13);
    --dui-color-primary: light-dark(#173528, #d7f5e3);
    --dui-color-primary-contrast: light-dark(#fff, #0f1a13);
    --dui-font-display: var(--dui-font-body);
    --dui-radius-control: 0.125rem;
    --dui-radius-surface: 0.25rem;
  }
</style>

Radius scale

<div class="grid">
  <section class="radius-panel stack" data-theme style="--dui-radius-scale: 0" aria-labelledby="radius-0-title">
    <h3 id="radius-0-title">Scale 0</h3>
    <p><button type="button">Secondary</button> <button type="submit">Save</button></p>
    <dui-menu>
      <button type="button" popovertarget="radius-0-menu">Menu</button>
      <div id="radius-0-menu" popover data-popover>
        <button type="button">Rename</button>
        <button type="button">Archive</button>
      </div>
    </dui-menu>
    <article data-card>
      <h4>A card</h4>
      <p>Square corners.</p>
    </article>
  </section>
  <section class="radius-panel stack" data-theme style="--dui-radius-scale: 1" aria-labelledby="radius-1-title">
    <h3 id="radius-1-title">Scale 1</h3>
    <p><button type="button">Secondary</button> <button type="submit">Save</button></p>
    <dui-menu>
      <button type="button" popovertarget="radius-1-menu">Menu</button>
      <div id="radius-1-menu" popover data-popover>
        <button type="button">Rename</button>
        <button type="button">Archive</button>
      </div>
    </dui-menu>
    <article data-card>
      <h4>A card</h4>
      <p>The default corners.</p>
    </article>
  </section>
  <section class="radius-panel stack" data-theme style="--dui-radius-scale: 1.5" aria-labelledby="radius-15-title">
    <h3 id="radius-15-title">Scale 1.5</h3>
    <p><button type="button">Secondary</button> <button type="submit">Save</button></p>
    <dui-menu>
      <button type="button" popovertarget="radius-15-menu">Menu</button>
      <div id="radius-15-menu" popover data-popover>
        <button type="button">Rename</button>
        <button type="button">Archive</button>
      </div>
    </dui-menu>
    <article data-card>
      <h4>A card</h4>
      <p>Rounder corners.</p>
    </article>
  </section>
</div>

Contrast

<div class="grid">
  <section class="radius-panel stack" data-contrast style="--dui-contrast: 0.8" aria-labelledby="contrast-08-title">
    <h3 id="contrast-08-title">0.8</h3>
    <p>Body text. <span class="muted">Muted text stays at 4.5:1.</span></p>
    <p><span data-badge="accent">New</span> <span data-badge="danger">Overdue</span></p>
    <div data-alert="info">
      <p><strong>Info:</strong> A tinted surface with a tinted border.</p>
    </div>
  </section>
  <section class="radius-panel stack" data-contrast aria-labelledby="contrast-1-title">
    <h3 id="contrast-1-title">1, the default</h3>
    <p>Body text. <span class="muted">Muted text.</span></p>
    <p><span data-badge="accent">New</span> <span data-badge="danger">Overdue</span></p>
    <div data-alert="info">
      <p><strong>Info:</strong> A tinted surface with a tinted border.</p>
    </div>
  </section>
  <section class="radius-panel stack" data-contrast="more" aria-labelledby="contrast-more-title">
    <h3 id="contrast-more-title">More</h3>
    <p>Body text. <span class="muted">Muted text, closer to the body text.</span></p>
    <p><span data-badge="accent">New</span> <span data-badge="danger">Overdue</span></p>
    <div data-alert="info">
      <p><strong>Info:</strong> A tinted surface with a tinted border.</p>
    </div>
  </section>
</div>

Inverse band

<section class="radius-panel stack" data-surface="inverse" aria-labelledby="inverse-band-title">
  <h3 id="inverse-band-title">Selected work</h3>
  <nav aria-label="Work">
    <ul class="cluster">
      <li><a href="#inverse-band-title" aria-current="page">All</a></li>
      <li><a href="#inverse-band-title">Apps</a></li>
      <li><a href="#inverse-band-title">Writing</a></li>
    </ul>
  </nav>
  <figure>
    <blockquote><p>Plain HTML that looks finished.</p></blockquote>
    <figcaption>A caption in muted text, still 4.5:1.</figcaption>
  </figure>
  <p><a href="#inverse-band-title">Read the case study</a></p>
</section>

Search