Atoms
Small additions to the base layer, for what a native element cannot express on its own. A level of Atomic Design; APIs follow the component API convention.
Pages
- Text helpers: Lead, small and muted text helpers from domestic-ui, with copyable markup. API:
data-text="lead | small | muted"(combinable). - Quiet link: A link that takes the surrounding text color and keeps its underline, for dense UI. API:
data-link="quiet"on<a href>;data-link="nav"keeps a navigational link outside a<nav>out of the visited color (combinable). - Buttons: Button variants and sizes, links styled as buttons, and disabled and loading states. API:
data-button="[primary | secondary | quiet] [small | large] [icon]"on<button>,<input type=submit|button|reset>,<a href>; statesdisabled,aria-disabled="true",aria-busy="true". - Form controls: Native form controls as styled by the domestic-ui base layer, with copyable markup. API: No API; native elements.
- Switch: An on/off switch built on a native checkbox with role switch, following the APG Switch pattern. API:
role="switch"on<input type="checkbox">. - Field: Label, control, hint and error message wired with aria-describedby and aria-invalid. API:
data-fieldon the wrapper,data-field-hintanddata-field-erroron the messages. - Badge: Inline status labels with tone variants that meet WCAG AA contrast. API:
data-badge="neutral | accent | success | warning | danger". - Icon: Inline Lucide SVG icons sized by a token, icon and label buttons, and icon-only buttons with a name and a tooltip. API:
data-iconon an inline<svg>copied from Lucide;data-icon="mirror"flips a directional icon in right-to-left text.
Our choices
From css/components/atoms/README.md:
- Our choice: one
data-<atom>attribute per atom, whose value is a space-separated list matched with~=. One attribute is one API to learn, it reads as a sentence (data-button="primary small"), and it cannot pile up like modifier classes. - Our choice:
data-buttonwith no variant word keeps the native default (a submit button is primary, everything else is secondary), so M1 markup keeps working and the attribute is only needed when the native type does not match the emphasis you want. - Our choice: the secondary button sits on the page surface with a softer border (
--dui-color-border-button, neutral step 7) and a 1px shadow. Its visible text label identifies it, so WCAG 1.4.11 does not require a 3:1 boundary; fields, selects, checkboxes, radios and switches keep the 3:1--dui-color-border-control. - Our choice: the quiet button uses the accent color for its text, so it still reads as interactive without a border, and its hover and pressed fills are neutral steps 4 and 5. Use it next to other buttons, not inside running text, where a real link belongs.
- Our choice: buttons, fields, selects and badges use the 14px interface size (
--dui-font-size-ui). Fields, selects and text areas use--dui-font-size-field, which is at least 16px under a coarse pointer, because iOS Safari zooms into a focused field with smaller text. - Our choice: primary buttons add an inner focus ring in their text color on top of the shared outline, so the indicator contrasts with the fill as well as the surface. This is the double-ring technique described in WCAG technique C40.
- Our choice: default buttons and fields are 36px tall and large ones 40px, and a coarse (touch) pointer restores 44px, between Primer and Radix (32px) and Material (40px), for comparison.
- Our choice: small buttons are 32px tall: below the 36px default, above the 24px minimum.
- Our choice:
aria-disabled="true"looks exactly likedisabled. Prefer nativedisabled; usearia-disabledwhen users should be able to reach the control and read why it is unavailable. - Our choice: the field's error text starts with the word "Error:" in the markup, rather than a CSS icon, so every user and every screen reader gets it with no extra API. Invalid controls also get a 3px halo around them, a shape change as well as a color change.
- Our choice: errors are tied to controls with
aria-describedby, notaria-errormessage, becausearia-describedbyhas broader screen reader support today (see the support notes on MDNaria-errormessage). - Our choice: the switch is the native checkbox with
role="switch", drawn withappearance: noneand one pseudo-element. The thumb moves and changes color, and forced-colors mode gets explicit system colors. - Our choice: badge tones are 8% of the tone mixed into the surface, with the tone as text. The tinted surfaces are derived tokens (
--dui-color-*-surface), so a theme that changes the surface or a tone re-tints badges with no extra overrides. - Our choice: icons are Lucide SVGs pasted inline, with no icon files, sprite, font or package in the repository, because Lucide already draws in our 24px, 2px,
currentColorstroke and inline SVG needs no build and follows forced colors. The hook isdata-iconon the<svg>, the same one-attribute rule as every atom, rather thansvg[aria-hidden], which would also style meaningfulrole="img"graphics and tie the look to an accessibility attribute. The rules for when to use an icon are in PRINCIPLES.md. - Our choice: an icon-only button (
data-button="icon") is named by visually hidden text inside it, notaria-label, because real text is translated by browser translation tools and copied with the page. Its<dui-tooltip>shows the same words and isaria-hidden, so the name is announced once; with JavaScript off the button keeps its name. - Our choice: a field is an atom here, not a molecule, because a control is not usable without its label, hint and error. Larger compositions (forms, cards, headers) are molecules and organisms for later milestones.
Not shipped, and why
| Candidate | Decision |
|---|---|
| Divider | Cut. <hr> is the native thematic break and is already styled in the base layer. A class would duplicate it. |
| Avatar | Cut. There is no standard or APG pattern for it; it is an <img alt> with a radius and a size, which the base layer and one line of your CSS already give. Revisit with a real use case (initials fallback, image loading). |
| Danger button variant | Not added. Not requested, and a destructive action is better marked by its label and a confirmation <dialog> than by color. Easy to add later as one more variant word. |
| Spinner for loading | Not added. The honest state is the changed label plus aria-busy; a spinner that replaces the label hides it from everyone. |