# Molecules

Small groups of atoms that work as one unit. A level of [Atomic Design](https://atomicdesign.bradfrost.com/); APIs follow the [component API convention](https://domestic-ui.odonckers.dev/index.md#component-api).

## Pages

- [Alerts](https://domestic-ui.odonckers.dev/patterns/alerts.md): Status messages, from notices in the page to live alerts and toasts.
- [Breadcrumb](https://domestic-ui.odonckers.dev/patterns/breadcrumb.md): The path to the current page: an ordered list of links in a labelled `<nav>`.
- [Card](https://domestic-ui.odonckers.dev/patterns/card.md): A self-contained item, such as an article teaser, on a raised surface.
- [Disclosure](https://domestic-ui.odonckers.dev/patterns/disclosure.md): A summary that shows or hides more content, built on `<details>` and `<summary>`.
- [Menu button](https://domestic-ui.odonckers.dev/patterns/menu-button.md): A button that opens a menu of actions.
- [Pagination](https://domestic-ui.odonckers.dev/patterns/pagination.md): Links to the pages of a long list of results.
- [Popover](https://domestic-ui.odonckers.dev/patterns/popover.md): Content shown on top of the page from a button, with the `popover` attribute.
- [Search](https://domestic-ui.odonckers.dev/patterns/search.md): A search form in a `<search>` landmark with an `<input type="search">`.
- [Search dialog](https://domestic-ui.odonckers.dev/patterns/search-dialog.md): A command palette: a modal `<dialog>` holding a combobox of pages and sections, opened from a Search button or with Cmd-K or Ctrl-K.
- [Tabs](https://domestic-ui.odonckers.dev/patterns/tabs.md): Sections of content shown one at a time, chosen from a list of tabs.
- [Toolbar](https://domestic-ui.odonckers.dev/patterns/toolbar.md): A row of related controls that is one stop in the tab order.
- [Typeahead](https://domestic-ui.odonckers.dev/patterns/typeahead.md): A text field that suggests values as you type: `<datalist>` first, an APG combobox where it falls short.
- [Account menu](https://domestic-ui.odonckers.dev/patterns/account-menu.md): The signed-in person's name and email, links to their account pages and a sign-out button, in a popover.
- [Empty state](https://domestic-ui.odonckers.dev/patterns/empty-state.md): What a list or table shows before it has anything in it, with the action that adds the first item.
- [Notifications list](https://domestic-ui.odonckers.dev/patterns/notifications-list.md): Recent events, newest first, each a linked sentence with the time it happened.
- [People list](https://domestic-ui.odonckers.dev/patterns/people-list.md): A list of people, each with a name, an email and a role badge at the end of the row.

## Our choices

From [`css/components/molecules/README.md`](https://github.com/odonckers/domestic-ui/blob/main/css/components/molecules/README.md):

- **Our choice:** native first, even where it differs from the APG example. The accordion is `<details name>`, so there are no heading wrappers and no arrow keys between headers (both optional in the APG); nav groups are `<details>` rather than scripted disclosure buttons, so they do not close on <kbd>Esc</kbd>. Both work with no script and keep find-in-page.
- **Our choice:** the drawer is a `<dialog>` variant (`data-dialog="drawer"`), not a new element or a popover, so it gets modality, inertness, focus handling and <kbd>Esc</kbd> from the browser. See [Drawer explainer](https://domestic-ui.odonckers.dev/explainers/drawer.md).
- **Our choice:** dialog and drawer motion uses `@starting-style` and `transition-behavior: allow-discrete`, declared after a plain transition, so engines without them simply open and close instantly. Duration tokens are `0s` under reduced motion.
- **Our choice:** anchored popovers fall back to the bottom center of the viewport where CSS anchor positioning is missing, rather than the browser's default center, so they never cover the middle of the content.
- **Our choice:** inactive nav rows use the muted text color (still 4.5:1) and get full-strength text on hover and when current; the current row also gets an accent tint behind the label and keeps its accent bar, and the selected tab becomes a raised segment with a 3:1 border, so the state never relies on color alone. Nav, menu and listbox rows and tabs use the 14px interface size.
- **Our choice:** automatic tab activation (selection follows focus), as the [APG recommends](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/#deciding-when-to-make-selection-automatically-follow-focus) when panels show without delay; `activation="manual"` is one attribute away.
- **Our choice:** tabs are written as a `<nav>` of in-page links and `<section>` panels, so they read as a table of contents with JavaScript off. Once upgraded, each panel's first heading is visually hidden (it repeats the tab label) but stays in the accessibility tree.
- **Our choice:** `<dui-menu>` adds `role="menu"` and `role="menuitem"` itself. Without the script there are no menu roles, so assistive technology is never promised arrow keys that do not work. A list of links is never a menu; use a disclosure.
- **Our choice:** `<dui-combobox>` upgrades a native `<input list>` + `<datalist>`, not a `<select>`, because the value is free text and the upgrade reuses the same input and options. Its listbox is positioned under the input inside the component (not a top-layer popover), so it is never wider than the field. Options are filtered by "contains", case-insensitive, like the native datalist popups in Chromium and Firefox. See [Combobox (typeahead) explainer](https://domestic-ui.odonckers.dev/explainers/combobox.md).
- **Our choice:** `<dui-toolbar>` keeps `role="toolbar"` in the markup, because a labelled group of Tab stops is still correct without the script; only the roving focus is added.
- **Our choice:** navigation lists (nav, tabs, pagination) drop the link underline, because their role is clear from the list ([F73](https://www.w3.org/WAI/WCAG22/Techniques/failures/F73) is about links in running text); hover brings it back. Breadcrumb links keep it, because they read as text.
- **Our choice:** "current" is never color alone: the nav item gets an accent bar, a tint and bold text (in a sidebar too: the nav molecule is the app shell's sidebar navigation, extended with decorative icons rather than forked into an organism, so there is one navigation API); the current page in pagination is filled and bold; the selected tab gets a raised, bordered segment and full-strength text.
- **Our choice:** the current page in pagination stays a link with `aria-current="page"`, and a disabled Previous or Next is an `<a>` with no `href`, which HTML defines as a placeholder: not focusable and not a link. See [Pagination explainer](https://domestic-ui.odonckers.dev/explainers/pagination.md).
- **Our choice:** a clickable card puts the link on its heading and stretches the link's hit area with a pseudo-element, so the card's accessible name is the heading and secondary actions in the footer stay separate links. See [Card explainer](https://domestic-ui.odonckers.dev/explainers/card.md).
- **Our choice:** alert tones start with a word in the markup ("Warning:"), like the field's "Error:", and add a decorative icon drawn in CSS with empty alternative text.
- **Our choice:** an `info` tone with its own token (`--dui-color-info`) instead of reusing the accent, so a green or red brand accent never makes an informational message look like success or danger.
- **Our choice:** toasts never dismiss themselves and never take focus; each has a Dismiss button, and the region is a fixed element in the page (not a popover) so server-rendered messages show with JavaScript off. See [Toast explainer](https://domestic-ui.odonckers.dev/explainers/toast.md).
- **Our choice:** the tooltip uses inverse colors (`--dui-color-surface-inverse` and `--dui-color-text-inverse`, derived from the text and surface tokens), so every theme gets a readable tooltip with no extra overrides.

## Not shipped, and why

| Candidate | Decision |
| --- | --- |
| Combobox with inline autocomplete, select-only combobox, multi-select | Not added. `<dui-combobox>` is the APG list autocomplete variant; a select-only combobox is a `<select>`, and inline completion and multiple values need their own use cases. |
| Vertical tabs | Not added. The APG allows them (`aria-orientation="vertical"`), but they need a different layout and Up/Down keys; add them with a real use case. |
| Menubar, submenus | Not added. Application menubars are rare on the web, and submenus are hard to use; a menu button covers actions. |
| Arrow-key navigation between accordion headers | Not added. It is optional in the APG Accordion pattern, and native `<details>` gives every summary a Tab stop. |
| Tree view for navigation | Not used. An [APG Tree View](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/) is for hierarchies users navigate as data (file trees), with one Tab stop and arrow keys; site navigation is links, so the sidebar navigation is disclosure groups and links ([APG Disclosure Navigation](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)). |
| Auto-dismissing toasts | Not added on purpose; see Our choices and [toast.md](https://domestic-ui.odonckers.dev/explainers/toast.md). |
| `interestfor` tooltips | Not used yet. It is the coming standard for hover and focus invokers but ships only in Chromium; `<dui-tooltip>` does the job until it is interoperable. |
