@apliteni/apliteni-ui 0.151.0 → 0.155.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/TRADEMARK.md +22 -0
- package/docs/components.md +1395 -0
- package/docs/foundations.md +494 -0
- package/guidelines/dashboards-and-reports.md +14 -0
- package/package.json +5 -2
- package/react/dist/index.css +8 -0
- package/react/dist/index.d.ts +14 -5
- package/react/dist/index.js +469 -363
- package/src/styles/card.css +12 -0
- package/src/styles/chart.css +6 -0
- package/src/styles/tap-zone.css +8 -0
|
@@ -0,0 +1,1395 @@
|
|
|
1
|
+
# Components (`@apliteni/apliteni-ui`)
|
|
2
|
+
|
|
3
|
+
A design system of tokens, one stylesheet per component, and React components. The root entry
|
|
4
|
+
publishes the helpers the React components share — `icon`, `prism`, `sun`, `moon`, `brand`,
|
|
5
|
+
`esc`, `safeUrl`, the motion helpers and the shared logic.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { icon } from '@apliteni/apliteni-ui';
|
|
9
|
+
icon('check');
|
|
10
|
+
// → '<svg viewBox="0 0 24 24" …>'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This page describes what ships, what to import, every published name, and what each component
|
|
14
|
+
promises. [foundations.md](foundations.md) covers the other half: the tokens and the floors.
|
|
15
|
+
The design rules for a screen are in [the guidelines](../guidelines/overview.md). React's notes
|
|
16
|
+
are in [react/README.md](../react/README.md).
|
|
17
|
+
|
|
18
|
+
## Entry points
|
|
19
|
+
|
|
20
|
+
| Import | Use |
|
|
21
|
+
|--------|-----|
|
|
22
|
+
| `@apliteni/apliteni-ui` | The helpers and shared logic (`icon`, `prism`, `brand`, `esc`, `safeUrl`, …), with TypeScript declarations. |
|
|
23
|
+
| `…/css` | The whole stylesheet, for bundler/browser builds. |
|
|
24
|
+
| `…/inline` | CSS as **strings**, for server-render inlining (`tokensCss`, `topbarCss`, `cssText`, …). |
|
|
25
|
+
| `…/tokens`, `…/accents` | Just the tokens / accent sub-themes. |
|
|
26
|
+
| `…/react`, `…/react/css` | The React wrapper over the same CSS, and its own stylesheet. |
|
|
27
|
+
| `…/motion` | The motion helpers. |
|
|
28
|
+
| `…/guidelines/*` | The guideline pages, as Markdown. |
|
|
29
|
+
|
|
30
|
+
There is no runtime dependency and no build step between the source and the stylesheet you read.
|
|
31
|
+
You can ship the package as it is. `…/css` and `…/inline`'s `cssText` contain the same
|
|
32
|
+
stylesheets in the same cascade order. If you take individual sheets from `styles`, you must
|
|
33
|
+
also take every sheet the component needs. For example, `successPanel()` needs `styles.callout`
|
|
34
|
+
and `styles.success`, both after `tokensCss` and `baseCss`.
|
|
35
|
+
|
|
36
|
+
### The React stylesheet does not re-emit a kit sheet
|
|
37
|
+
|
|
38
|
+
Import `@apliteni/apliteni-ui/css` first, then import `@apliteni/apliteni-ui/react/css`. You
|
|
39
|
+
need both. The React stylesheet contains what React's own components add. It does not contain a
|
|
40
|
+
second copy of the kit.
|
|
41
|
+
|
|
42
|
+
**The kit CSS is a peer, not a dependency of a React component.** If a React module imported a
|
|
43
|
+
kit sheet, that sheet would be re-emitted into `react/dist/index.css`. It would then appear after
|
|
44
|
+
the kit's own copy in your document. At equal specificity, it would overrule the kit's copy.
|
|
45
|
+
|
|
46
|
+
Four sheets travel with the React bundle. They do so because changing their order cannot change
|
|
47
|
+
what they decide: the reduced-motion net, the 16px field net, the tap-zone sheet, and the hover
|
|
48
|
+
readout's sheet. Each is behind a media query or is written so it has no specificity to lose.
|
|
49
|
+
They support the consumer who uses `@apliteni/apliteni-ui/react/css` alone.
|
|
50
|
+
|
|
51
|
+
## Tokens & theming
|
|
52
|
+
|
|
53
|
+
Everything visual uses a CSS custom property. Two independent attributes on `<html>` control
|
|
54
|
+
those properties:
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<html data-theme="dark" data-accent="phoenix">
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **`data-theme`** = `dark | light` — controls surfaces, text, borders, and the fixed signal colours.
|
|
61
|
+
- **`data-accent`** = `phoenix | ocean | emerald` (absent = **Nebula**, the purple default) —
|
|
62
|
+
changes only the accent family, so every accent works in both themes without a component
|
|
63
|
+
change.
|
|
64
|
+
|
|
65
|
+
Neither attribute controls type. `--font-display` is for headings and brand marks,
|
|
66
|
+
`--font-sans` is for everything read, and `--font-mono` is for code. Neither font family ships
|
|
67
|
+
with the package. The host page loads both. See [Typefaces](foundations.md#typefaces).
|
|
68
|
+
|
|
69
|
+
`applyTheme('light')` and `applyAccent('phoenix')` save their values to `localStorage`.
|
|
70
|
+
`ACCENTS` lists the names that `applyAccent` accepts. You can also ship `accentPicker()` and
|
|
71
|
+
let `wireTopbar()` handle it.
|
|
72
|
+
|
|
73
|
+
### An absent attribute means dark
|
|
74
|
+
|
|
75
|
+
`data-theme` and `data-accent` are optional **overrides**. If neither attribute is present, the
|
|
76
|
+
kit renders dark Nebula.
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<html> <!-- dark, Nebula -->
|
|
80
|
+
<html data-accent="ocean"> <!-- dark, Ocean -->
|
|
81
|
+
<html data-theme="light"> <!-- light, Nebula -->
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Component catalog
|
|
85
|
+
|
|
86
|
+
Each published name appears once, with the section that defines its behaviour. The options show
|
|
87
|
+
what a factory accepts. They do not describe what the factory does.
|
|
88
|
+
|
|
89
|
+
### Content and status
|
|
90
|
+
|
|
91
|
+
| Name | What it is |
|
|
92
|
+
|------|------------|
|
|
93
|
+
| `button({ label, variant, size, icon, iconRight, block, disabled, busy, href, iconOnly })` | `<button>`, or `<a>` with `href`. See [Extra-small buttons](#extra-small-buttons). |
|
|
94
|
+
| `setButtonBusy(element, { busy })` | Flips a mounted button to its busy state and back. See [Busy button labels](#busy-button-labels). |
|
|
95
|
+
| `badge(label, variant)`, `pill(label, variant)`, `statusDot(live)` | Status chip, rounded chip, live dot. |
|
|
96
|
+
| `avatar({ key, name, initials, src, size, empty })`, `avatarHue(key)`, `avatarInitials(name)`, `AVATAR_HUES` | A person's mark. See [Avatar](#avatar). |
|
|
97
|
+
| `card({ title, sub, body, variant, pad, icon, level })` | Surface container. `title` and `sub` are trusted markup; keep the title to inline content. |
|
|
98
|
+
| `callout`, `toast`, `successPanel` | Inline feedback inside the page the reader is on; `calloutIcons` is the default glyph per tone. |
|
|
99
|
+
| `pushToast(container, opts)`, `dismissToast(el)`, `wireToastStack(container)` | The runtime toast stack. |
|
|
100
|
+
| `success({ layout, check, level, title, body, actions, confetti, countdown })` + `wireSuccess(root)` | Page-sized confirmation; `successCheck()` is its mark alone. See [Success confirmations](#success-confirmations) and [successPanel or success?](#successpanel-or-success). |
|
|
101
|
+
| `emptyState({ art, icon, title, sub, actions })` | Placeholder for an empty list, table or page; `art` is an `illo()` name or raw SVG. |
|
|
102
|
+
| `deniedState({ title, sub, need, actions, icon })` | The 403, in the same layout language. See [Pending and denied states](#pending-and-denied-states). |
|
|
103
|
+
| `busyRegion({ label, readyLabel, busy, body, lines })` + `setBusy(root, …)` | The screen's pending state, and the only thing in the kit that announces one. |
|
|
104
|
+
| `skeleton({ lines, width, height, radius })`, `skeletonTable({ rows, cols, head })` | Placeholder shapes, `aria-hidden` throughout. |
|
|
105
|
+
| `snippet({ label, code, reveal, copy, copyLabel })` | Code block with an icon-only copy button. `hlCode(raw, lang)`, `hlShell(raw)` and `codeTokens(raw, lang)` highlight what `codeLanguages` lists. See [Code highlighting](#code-highlighting). |
|
|
106
|
+
| `icon(name, cls)`, `illo(name)`, with `iconNames`, `iconCategories`, `illoNames` | Line icons and illustrations as SVG strings; `sun` and `moon` are exported bare too. |
|
|
107
|
+
| `iconOnlyAllowed`, `iconOnlyNames`, `iconMeanings` | The icon rulings as data. `iconOnlyNames` gives each wordless glyph the words its button’s name may open with, so `copy` cannot be borrowed for Duplicate. See [Icons and glyphs](foundations.md#icons-and-glyphs). |
|
|
108
|
+
| `seedling`, `prism`, `brand` | The brand mark. |
|
|
109
|
+
|
|
110
|
+
`card()` and React `<Card>` share the default, accent, and live surfaces. Use `icon` for a title chip. Use `pad="sm"` for less vertical space or `pad="lg"` for a centred landing card. A setting row keeps its choice on one line. On phones, its control sits below its label and hint. At wider widths, a choice that cannot fit beside its label moves below it. An accent card keeps its tint without a coloured edge. Use `href` on React `<Card>` to make the whole card a link. Use `tools` on a titled React `<Card>` for small controls at the end of the title row, such as an icon-only Download PDF button. A `<Chart>` in a titled card puts its Chart and Table switch there. The tools are centred on the title's line, on a desktop and on a phone, so the card has no extra row. On a touch phone the tools sit `--tap-gap` apart, so a tap on one never runs its neighbour. In the vanilla kit, wrap the title and a `.ui-card__tools` block in `.ui-card__head`.
|
|
111
|
+
Three-option setting rows use `ui-card__row--tight-choice` to narrow pills below 360 px and stay on one line, while other rows keep full tap width.
|
|
112
|
+
To show a document inside a card, wrap a `.ui-toolbar` and a `.ui-table-scroll` in `.ui-card__viewer`, and give the document `.ui-card__page`. The toolbar becomes a slim row between two hairlines. The scroll box becomes a recessed stage that runs to the card's sides and bottom. The page is a white sheet with dark text in both themes, with A4 proportions at the least. Its table, lines and loading skeleton take the light palette too.
|
|
113
|
+
|
|
114
|
+
### Controls and input
|
|
115
|
+
|
|
116
|
+
| Name | What it is |
|
|
117
|
+
|------|------------|
|
|
118
|
+
| `field({ label, hint, error, control, required })` | The label, hint, error and ARIA wiring a control cannot do itself. See [Forms](#forms). |
|
|
119
|
+
| `input`, `textarea`, `select`, `checkbox`, `switchToggle` | The controls `field` wraps; each also renders on its own. |
|
|
120
|
+
| `segmented({ options, active, size, block, name, ariaLabel })` + `segmentedNextIndex(key, index, length)`, `initSegmented(root)` | Toolbar of toggle buttons. See [Segmented or tabs?](#segmented-or-tabs) and [Segmented strips that outgrow their column](#segmented-strips-that-outgrow-their-column). |
|
|
121
|
+
| `tabs({ items, active, name, ariaLabel })` + `initTabs(root)` | Tablist and its panels, one per item. |
|
|
122
|
+
| `dropdown({ label, value, variant, items, sections, foot, header, footer, align, direction, portal, scroll, search, disabled })` + `wireDropdown(root)` | Popover list, as a listbox or an action menu. `disabled: true` turns the trigger off: no keyboard stop, no panel, and the kit's unavailable paint. `portal: true` is the answer for a dropdown inside the shell's rail. `dropdownMatch(label, query)` and `dropdownFiltering(query)` are its filter, published so a second implementation asks the kit. `filterPanelFit(dd, floor)` with `DD_MENU_FLOOR` is the same for an anchored filter menu: inside `.ui-filter-bar` an **open** menu takes the kit's 240px floor rather than its trigger's width, and a shut one keeps the trigger's. `filterPanelRow(dd)` answers which row such a menu is measured inside: a chip's, or one asking for a width with `--ui-filter-panel-ask`. `dropdownViewportFit(panel)` answers for a panel outside a filter row: how wide it may be and how far it has to move to stay inside the view it is laid out in. `--ui-dropdown-edge` is the gap it keeps from the view's edge. `dropdownHeightFit(dd, panel)` answers how tall an **open** panel may be, which is the room between its trigger and the viewport edge it opens towards. It answers nothing for a closed panel. `dropdownReveal(dd, panel)` scrolls a Modal or Drawer body the least distance that shows an open panel, and answers how far it scrolled; the dropdown wiring calls it for you. `dropdownSnap(dd, panel)` stops an open panel's height in the middle of a row, for any row height and against the measured room; the wiring calls it too, and it keeps a cap the consumer asked for to its number. `dropdownRest(dd, panel, open)` gives an open panel its box and collapses a shut one after its fade, so a shut panel adds no scroll room; the wiring calls it too. `dropdownLift(dd, panel)` lifts an open panel out of a body too short to hold it, or too narrow to show it across, and answers whether it did; the wiring calls it too. See [The dropdown panel](#the-dropdown-panel), [A dropdown with a search field](#a-dropdown-with-a-search-field) and [A filter row holds its panels](#a-filter-row-holds-its-panels). |
|
|
123
|
+
| `filterBar(options)` + `initFilterBar(host, options)`, with `filterChipText`, `filterChipName`, `filterChipUnset`, `filterChipItems`, `nextFocusStop`, `focusNextStop` | The controlled filter row above a table. The consumer owns the filters and calls `update()`. `filterChipItems(filter)` marks the chip's own value in the items it hands its menu, so the line the chip prints and the row the menu marks cannot disagree; a chip that is unset, or whose value is in no row, marks nothing, and a `selected` the consumer set does not stand in for it. `nextFocusStop(host)` names where an emptied bar sends the focus — the way to add a filter still on the row, drawn from `data-filter-add`, else the control a reader's next <kbd>Tab</kbd> would reach; `focusNextStop(host)` puts it there, skipping anything the reader cannot reach, and answers with the element it ended on. See [A filter row holds its panels](#a-filter-row-holds-its-panels). |
|
|
124
|
+
| `pagination({ page, pageSize, total, hasMore, pageSizes, variant, label, loading, href, id })` + `wirePagination(root, …)`, `setPagerStatus(root, text)`, `PAGE_SIZES`, `DEFAULT_PAGE_SIZE` | The strip under a table or list; it renders a page the caller already computed. See [Pagination](#pagination). |
|
|
125
|
+
| `commandPalette({ groups, items, label, placeholder, query, empty, density, hint, rank, hotkey, open, specimen, id })` + `wireCommandPalette`, `openCommandPalette`, `closeCommandPalette`, `commandPaletteList`, `setPaletteResults`, `rankCommands`, `rankGroups`, `scoreCommand`, `SCORE`, `paletteHotkey()` | The ⌘K overlay and the ranking behind it; `SCORE` is the ladder itself, for a server that sorts the same way. See [The command palette](#the-command-palette). |
|
|
126
|
+
| `feedbackWidget()` + `wireFeedback(…)`, `nearestSection(node, root)` | Select a passage, give feedback. |
|
|
127
|
+
|
|
128
|
+
### Overlays
|
|
129
|
+
|
|
130
|
+
| Name | What it is |
|
|
131
|
+
|------|------------|
|
|
132
|
+
| `drawer({ side, size, title, body, footer, open, specimen, dismissible })` + `wireDrawer`, `openDrawer`, `closeDrawer`, and `drawerSection({ title, rows, body })` for one group of its body | Panel against a screen edge, over a scrim. See [The drawer](#the-drawer). |
|
|
133
|
+
| `confirm({ title, body, confirmLabel, cancelLabel, variant, open, specimen, id })` + `wireConfirm`, `openConfirm`, `closeConfirm` | Modal question over a scrim, for a destructive action the page has to stop for. |
|
|
134
|
+
| `tooltip({ label, value, detail, placement, open, x, y, id })` + `wireTooltip`, `showTooltip`, `hideTooltip` | The readout over a chart mark, on hover or tap. See [The hover readout](#the-hover-readout). |
|
|
135
|
+
|
|
136
|
+
Both `drawer()` and `confirm()` accept `specimen: true`. This draws an example for a
|
|
137
|
+
documentation page. It does not add `aria-modal`, wiring or Escape handling.
|
|
138
|
+
|
|
139
|
+
### Figures and tables
|
|
140
|
+
|
|
141
|
+
| Name | What it is |
|
|
142
|
+
|------|------------|
|
|
143
|
+
| `statBand({ stats, variant, basis, basisId, label, id })`, with `STAT_VARIANTS`, `STAT_TONES` | A row of key figures as a `<dl>`. A figure is `{ label, value, caption, delta, trend }`; `basis` is what every change is measured against, and the kit draws no chart. See [Stat bands](#stat-bands). |
|
|
144
|
+
| `numericValue({ value, unit, missing })`, `deltaValue({ value, tone, basisId })` | Inline value and inline change. Colour never supplies the sign. |
|
|
145
|
+
| `rowIdentity({ symbol, name, logo, href })` + `initRowIdentity(root)` | A company identity cell, with a letter fallback. |
|
|
146
|
+
| `formatNumericValue(…)`, `formatDeltaValue(…)` | The same two decisions as plain text, shared with React. |
|
|
147
|
+
| `chartScale(values, options)`, `bridgeWalk(steps)`, `pointTarget(point, options)`, `CHART_FLOOR` | The arithmetic a chart needs, with no DOM and no pixels: the band a series is drawn in with its whole-unit ticks, each bridge column's own amount and the two ends of the bar that draws it, and where a pointer target sits over a drawn point. The kit draws no chart of its own; React `Chart` is the one here that uses them. See [React charts](#react-charts). |
|
|
148
|
+
|
|
149
|
+
The table is markup, not a factory. The page adds the scroll region, sticky header and pinned
|
|
150
|
+
identity column through classes. See
|
|
151
|
+
[Dense financial tables](#dense-financial-tables).
|
|
152
|
+
|
|
153
|
+
### Page furniture
|
|
154
|
+
|
|
155
|
+
| Name | What it is |
|
|
156
|
+
|------|------------|
|
|
157
|
+
| `appShell({ word, brandHref, nav, active, navLabel, back, title, sub, body, account, signOutHref, layout, width, search, topbar, maxWidth, collapsible, collapsed })` | The kit's one page shell, and the one to call for new work. See [The page shell](#the-page-shell) and [The second layout](#the-second-layout). |
|
|
158
|
+
| `wireShell(root, { persist })` + `railCollapsed(cookieHeader?)`, `RAIL_COOKIE` | Wires the rail's fold, the reader's menu and the nav's groups; the cookie lets a server paint the right width first. |
|
|
159
|
+
| `nav({ variant })`, dispatching to `sidebarNav` or `navTabs`, + `wireNav(root)` | Wayfinding. Each shape is also exported on its own. `wireNav` opens the sidebar's groups, sizes a tab row to its links on load and on resize, scrolls the row to its current link, and scrolls it to a link the keyboard lands on. See [A tab row scrolls inside its column](#a-tab-row-scrolls-inside-its-column). |
|
|
160
|
+
| `backLink({ href, label })` | The way up to the page this one sits under — an `<a href>`, never a history step. See [The back link](#the-back-link). |
|
|
161
|
+
| `topbar(…)` + `wireTopbar(root)` | The product topbar. `themeToggle(theme)`, `accountMenu({ name, email, active, nav, initials })`, `versionSwitcher(versions, activeIdx)` and `deckTextSwitch(active)` are its parts, usable alone; `themeIcon(t)` and `themeName(t)` label your own toggle. |
|
|
162
|
+
| `accentPicker({ active, options })`, with `ACCENTS` and `accentSwatchStyle(accent)` | The accent swatches, wired by `wireTopbar()`. `ACCENTS` is the list the kit ships; `accentSwatchStyle(accent)` is the one custom property a swatch button carries, `--swatch`, the gradient its circle wears. Both pickers read them, so a page building its own strip paints the same thing — and the kit's stylesheet draws the selected swatch's tick, so the strip needs no selection paint of its own. An accent with no paints gets `--swatch: transparent`, an empty circle you can still press. |
|
|
163
|
+
| `ACCOUNT_NAV` | The account navigation the kit ships, as `sidebarNav()` items; the account menu falls back to it and your own entries replace it. |
|
|
164
|
+
| `footer({ variant, brand, tagline, columns, social, legal, legalLinks, switcher })` | Site or app footer: `full`, `slim` or `app`. |
|
|
165
|
+
| React `Footer` | The same three footer variants. The full footer puts link columns side by side above the phone width and stacks them on a phone. Pass React content for the brand, links, legal row and switcher. |
|
|
166
|
+
| `.ui-toolbar` (class, no factory) | A row of controls above a list. See [A toolbar at one column](#a-toolbar-at-one-column). |
|
|
167
|
+
|
|
168
|
+
### Motion and escaping
|
|
169
|
+
|
|
170
|
+
| Name | What it is |
|
|
171
|
+
|------|------------|
|
|
172
|
+
| `prefersReducedMotion()`, `staggerDelay`, `initReveal`, `replay`, `playEntrance`, `transitionMs(el)`, `ENTRANCE_FALLBACK_MS` | The motion helpers. `transitionMs(el)` answers how long the stylesheet says an element's transition lasts, so a caller sizing a backstop timer for a fade reads the sheet rather than copying a duration token; a missing or non-element argument answers `0`, which fires at once rather than never. See [Motion](foundations.md#motion). |
|
|
173
|
+
| `esc(s)` | HTML-escape a text value. Every factory already applies it to its own text arguments; you need it for markup you assemble yourself. |
|
|
174
|
+
| `safeUrl(url, fallback?)` | The URL boundary every factory sends an `href` through: a `javascript:`, `data:` or `vbscript:` destination becomes the fallback, `#` unless you name another. You need it for markup you assemble yourself; the React components call this same function. See [Escaping and URL slots](#escaping-and-url-slots). |
|
|
175
|
+
| `observeNavFit(row)` | Observe changes to a tab row and its links without changing its scroll position. Call the returned function to stop observation. |
|
|
176
|
+
| `revealCurrentNav(row)` | Size one `.ui-nav--tabs` row to its links and bring its `aria-current` link inside it, moving neither focus nor the page. `wireNav()` calls it; call it yourself after replacing a row's links. |
|
|
177
|
+
| `revealFocusedNav(row, target)` | The same scroll for the link a focus event landed on, so the ring that link draws clears the row's scrolling edge. `target` is the event's target; a target that is not a tab in `row` is ignored. `wireNav()` wires it, and React's `NavTabs` calls it on focus. |
|
|
178
|
+
|
|
179
|
+
The public JS surface is the set of exports from the package entry. A module that the entry does
|
|
180
|
+
not name still ships in the tarball. You still cannot import it, because the package declares no
|
|
181
|
+
`./components/*` subpath.
|
|
182
|
+
|
|
183
|
+
## What each component guarantees
|
|
184
|
+
|
|
185
|
+
One short paragraph describes each component's promise. This is the promise a consumer would
|
|
186
|
+
otherwise need to discover. Each rule's test contains its detail. React's own notes are in
|
|
187
|
+
[react/README.md](../react/README.md).
|
|
188
|
+
|
|
189
|
+
### The page shell
|
|
190
|
+
|
|
191
|
+
`appShell()` is the kit's one way to compose a page. It draws the chrome, and you decide what
|
|
192
|
+
goes inside. It always draws **one `<main>` landmark** and gives every navigation landmark a
|
|
193
|
+
unique name. **The page title keeps the same step above your content whether or not you pass a
|
|
194
|
+
`sub`.** **Small tools for the whole page end the title row:** put the `h1` and a `.ui-app__tools`
|
|
195
|
+
group in a `.ui-app__title-row`, and the `.ui-app__sub` lede after the row. It does not render a topbar
|
|
196
|
+
unless you pass one. **The rail folds** above 720px through a `<button>` that the reader
|
|
197
|
+
presses. That button writes the `apliteni-ui-rail` cookie, so a server can first paint the folded
|
|
198
|
+
width with `railCollapsed()`. **At 720px and below the rail is a drawer.** The icon strip goes
|
|
199
|
+
away. A 52px band at the top holds a menu button at its start and the brand mark beside it. The
|
|
200
|
+
button opens the full rail in the left drawer, with its labels, its groups, its counts and the
|
|
201
|
+
reader's block at the foot. Pressing a row, pressing Escape or widening the page closes the
|
|
202
|
+
drawer, and focus returns to the menu button. A page in the topbar layout has a band already, so
|
|
203
|
+
the menu button joins that band and the page never has two. The reading column takes the full
|
|
204
|
+
width of the page. A folded row keeps its name and count for keyboard
|
|
205
|
+
and pointer users. Every control in it clears the 24px floor and shows the ring. **The current
|
|
206
|
+
row is one plate, at either width.** It is a quiet fill behind the row, a measured step off
|
|
207
|
+
whatever the rail stands on, and nothing closes it: no accent bar, no hairline and no outline,
|
|
208
|
+
because an outline on a rail row means focus alone. A row under the pointer takes a lighter wash
|
|
209
|
+
of the same fill, so the row the reader is on stays the louder of the two in both themes. Pass
|
|
210
|
+
`signOutHref` and the reader's block becomes a kit `dropdown()`, with signing out as one of its
|
|
211
|
+
rows. **The rail holds nothing that has to escape it**. It is sticky and scrolls. A dropdown
|
|
212
|
+
mounted inside it therefore passes `portal: true`, and the panel stands one measured step from
|
|
213
|
+
the page under every accent. `accountShell()` was retired in 0.81.0. Account and settings belong
|
|
214
|
+
in a modal over the product, as [Account and settings](../guidelines/account-and-settings.md)
|
|
215
|
+
says.
|
|
216
|
+
|
|
217
|
+
#### A folded rail takes the pointer only where it draws
|
|
218
|
+
|
|
219
|
+
A folded rail is one glyph column wide. Every box inside it is laid out in that column. This
|
|
220
|
+
includes the sections, lists, rows and the rule that the footer draws above itself. A click beside
|
|
221
|
+
the rail therefore lands on the page. A link reached by keyboard draws its full ring instead of
|
|
222
|
+
losing both ends to a clip. There is one limit: a folded rail flush with a page's right edge adds
|
|
223
|
+
175px to the page's scrollable width.
|
|
224
|
+
|
|
225
|
+
#### The second layout
|
|
226
|
+
|
|
227
|
+
`appShell({ layout: 'topbar' })` is the same shell with its three parts in different places.
|
|
228
|
+
Every guarantee above still applies. The band stands beside the rail. It does not span the top
|
|
229
|
+
of both. **The rail holds the shell's own controls:** the fold's control in its head, beside the
|
|
230
|
+
mark, the theme switch above the reader's block, and the reader's block at its foot. The band
|
|
231
|
+
control stands under the head (#732, `react/src/AppShell.tsx:191` `ui-react-app__control`). **The band carries the search
|
|
232
|
+
field and nothing else** above 720px. At 720px and below it carries the mark, the page title on one
|
|
233
|
+
line, the search trigger and the menu button (`react/src/AppShell.css:97` `@media (max-width: 720px)`). It is a `<header>`
|
|
234
|
+
outside the navigation landmark. The field is the palette's own trigger, drawn as a field, with
|
|
235
|
+
the key cap inside its accessible name. If no palette is named, there is no field. **One band over
|
|
236
|
+
a page, never two:** `layout: 'topbar'` and the compatibility `topbar` bag are not composed. An
|
|
237
|
+
unknown `layout` or `width` is read as the layout the kit has always drawn. React's own shell is
|
|
238
|
+
[React AppShell](#the-rest-of-the-react-surface).
|
|
239
|
+
|
|
240
|
+
**Below 560px the trigger shows only its search glyph, and is still called the same thing.** At
|
|
241
|
+
one column the band holds the trigger beside the mark, the page title and the menu button, so the sentence had a few characters to stand in and broke mid-word — "Search or
|
|
242
|
+
run a co…". The sentence and the key cap are **clipped rather than dropped** at that width, so the
|
|
243
|
+
button's accessible name is the same string at 1280px and at 390px: a control that says something
|
|
244
|
+
shorter to a screen reader on a phone is a second control. The clip is one block in `layout.css`.
|
|
245
|
+
The palette's own placeholder is not this text and does not shorten.
|
|
246
|
+
Decided in [#486](https://github.com/apliteni/apliteni-ui/issues/486). The short word that #486
|
|
247
|
+
drew there gave way to the glyph on [#729](https://github.com/apliteni/apliteni-ui/issues/729).
|
|
248
|
+
|
|
249
|
+
### The back link
|
|
250
|
+
|
|
251
|
+
`backLink()` is the way to reach the page that contains this one. You place it with
|
|
252
|
+
`appShell({ back })`. **It is a link to an address, never a step through the history**. If you
|
|
253
|
+
pass nothing or pass a `javascript:` one, it renders nothing. **It names where it goes:** it uses
|
|
254
|
+
the destination name written in the sidebar or trail. The arrow has `aria-hidden`, and a long name
|
|
255
|
+
clips instead of wrapping. **It takes the trail's place, above the title**. A page has one or the
|
|
256
|
+
other. The shell keeps the row you marked `active` lit as `aria-current="true"`. This marks the
|
|
257
|
+
current section, not the page. When a page should take one:
|
|
258
|
+
[Going back](../guidelines/going-back.md).
|
|
259
|
+
|
|
260
|
+
### A tab row scrolls inside its column
|
|
261
|
+
|
|
262
|
+
`navTabs()` lays its links out in one row and never wraps them. **When the links are wider than
|
|
263
|
+
the column, the row scrolls inside itself and the page does not widen.** A shade marks each edge with more tabs beyond it, on the page or on a card.
|
|
264
|
+
|
|
265
|
+
**The row stays aligned with the page gutter, and the active underline stays on the row rule.**
|
|
266
|
+
Call `wireNav()` for vanilla rows. React rows update automatically when their labels, badges,
|
|
267
|
+
or available width change.
|
|
268
|
+
Use `observeNavFit()` for custom rows, and call its returned function when removing the row.
|
|
269
|
+
Server-rendered or unwired rows keep their scroll containment.
|
|
270
|
+
|
|
271
|
+
**Keyboard navigation reveals each focused link with its complete focus band.**
|
|
272
|
+
The row scrolls without moving focus or scrolling the page. Content and container changes preserve the reader's scroll position where space permits.
|
|
273
|
+
When a link already fits in the row, it keeps its content width. The cap only limits one link
|
|
274
|
+
that is wider than the row.
|
|
275
|
+
|
|
276
|
+
**An overflowing row with only disabled tabs becomes a keyboard stop.**
|
|
277
|
+
It draws the kit's inward focus band. A fitting row supplies no separate keyboard stop.
|
|
278
|
+
|
|
279
|
+
### The current route has an accent label
|
|
280
|
+
|
|
281
|
+
**A selected pill tab uses an accent label on its soft accent fill.**
|
|
282
|
+
The label distinguishes the current route from a hovered route. The underline appearance keeps
|
|
283
|
+
body ink and its accent bar. Both appearances name the current route with `aria-current="page"`.
|
|
284
|
+
|
|
285
|
+
**In forced colours, both appearances retain a visible selected mark using the reader's system colours.**
|
|
286
|
+
The pill label and badge remain readable. Ordinary colours are unchanged.
|
|
287
|
+
|
|
288
|
+
### The dropdown panel
|
|
289
|
+
|
|
290
|
+
Inside a scrolling body, such as a Modal or a Drawer, a dropdown opens below its trigger and scrolls
|
|
291
|
+
the body the least distance that shows the whole panel, with the field's label and the trigger above
|
|
292
|
+
it. The body jumps instead of gliding under `prefers-reduced-motion`. Where the body is tall enough,
|
|
293
|
+
the panel ends `--ui-dropdown-shade`, which is 48px, above the body's end. The drop shadow fades out
|
|
294
|
+
by then, in light and in dark, so the body never clips it and the panel never touches the Modal
|
|
295
|
+
footer. A shorter body spends that room down to the 8px edge. A body that cannot hold the label, the
|
|
296
|
+
trigger, the 120px floor and the 8px edge lifts the panel out of the body. Examples are a Modal with
|
|
297
|
+
a short form and a Drawer on a phone held sideways. A body that hides what overflows across and is
|
|
298
|
+
narrower than the panel lifts it too, so a menu in the shell's rail shows its full width over the
|
|
299
|
+
page. A lifted panel opens over the body and its
|
|
300
|
+
footer the way a portalled panel does: below its trigger, or above it where the viewport has more
|
|
301
|
+
room. It follows the trigger while the body scrolls. The ancestor that scrolls is the one whose end
|
|
302
|
+
the reader sees, so a wrapper with `overflow: auto` that does not scroll is passed over, and the
|
|
303
|
+
panel is no taller than the smallest of them shows. A shut panel adds no scroll room at the end of a body or a page. While the reader is
|
|
304
|
+
still scrolled into the room that the open panel needed, that room stays, so closing the panel does
|
|
305
|
+
not move the field. It goes when the reader scrolls out of it. This holds for a page as well as a
|
|
306
|
+
body: at the end of a page, closing a panel with Escape leaves the field where it was.
|
|
307
|
+
|
|
308
|
+
`dropdown()` places its panel for you. You do not write a rule to move it. `direction` selects
|
|
309
|
+
where it opens: `'down'`, `'up'`, or `'auto'`. `'auto'` flips only when there is not enough room
|
|
310
|
+
below and there is more room above. The head and foot extend through the panel's padding to the
|
|
311
|
+
edge where they sit. **What goes in them is yours within the panel's role**. A `role="menu"` takes
|
|
312
|
+
menuitems. A `role="listbox"` takes options. A control in the foot of either role is refused by
|
|
313
|
+
`aria-required-children`. With `search: true`, the panel becomes a `role="dialog"`, where such a
|
|
314
|
+
control belongs. **`portal: true` lets the panel leave a trigger's subtree** when an ancestor's
|
|
315
|
+
`overflow` or `position: sticky` traps it. It stays opt-in because the panel then lands at the end
|
|
316
|
+
of the tree it was moved into. It never crosses a document or shadow-root boundary. **Escape is
|
|
317
|
+
scoped and click-outside is not**, and either action returns focus to the trigger. **A panel the
|
|
318
|
+
keyboard opens is visible in the frame the key lands**. An open panel has no transition inside it
|
|
319
|
+
at all. See
|
|
320
|
+
[Reduced motion travels with the stylesheet](foundations.md#reduced-motion-travels-with-the-stylesheet).
|
|
321
|
+
Every menu the kit ships follows those last two rules.
|
|
322
|
+
|
|
323
|
+
**A panel stays inside the view it is laid out in, open and closed.** `align` chooses the edge of
|
|
324
|
+
the trigger the panel hangs from. The panel keeps that edge wherever it fits and moves along the
|
|
325
|
+
row where it does not, which is the rule `direction: 'auto'` applies on the other axis. A closed
|
|
326
|
+
panel is placed by the same rule: it is hidden and still laid out, so it would otherwise widen the
|
|
327
|
+
page before anything is clicked. A panel adds nothing to the page's scrollable width at any width.
|
|
328
|
+
`--ui-dropdown-edge` is the gap a panel keeps from the edge of the view. Set it to 0 for a panel
|
|
329
|
+
flush with the edge, or wider for more room. A view that cannot afford the gap on both sides halves
|
|
330
|
+
it. At 720px and below the gap is the page margin, 16px, so a panel lines up with the page's text.
|
|
331
|
+
|
|
332
|
+
**A panel has a floor and a ceiling.** The floor is the kit's 240px, which is what makes a list of
|
|
333
|
+
rows readable. The ceiling is the view less that gap at each side. The floor wins where the two
|
|
334
|
+
disagree, which is a view narrower than 256px. A long unbroken token — a filename, a key, a URL —
|
|
335
|
+
breaks in the middle rather than reaching past the bound, so one row cannot make the panel wider
|
|
336
|
+
than the screen. The tradeoff is a broken word.
|
|
337
|
+
|
|
338
|
+
**An open panel never runs past the viewport edge, on the other axis either.** A wired panel is
|
|
339
|
+
capped at the room between its trigger and the edge it opens towards, less the gap it keeps from
|
|
340
|
+
the trigger and `--ui-dropdown-edge` at the edge, and scrolls inside that cap — the wheel over it
|
|
341
|
+
stops there too, rather than carrying on down the page underneath. The cap takes hold when a panel
|
|
342
|
+
opens, and also right away for a panel that is already open when the wiring reaches it. That is the
|
|
343
|
+
whole of [#489](https://github.com/apliteni/apliteni-ui/issues/489): before it an opened
|
|
344
|
+
panel took its content's height unless the consumer reached for the `scroll` modifier, so a
|
|
345
|
+
twelve-row menu opened 300px above the bottom of a 390×844 phone ended past the fold and its last
|
|
346
|
+
rows could not be reached, and the wheel over it scrolled the page instead. Capped, the same menu
|
|
347
|
+
ends inside the viewport and scrolls on its own. Two custom properties decide the height and the
|
|
348
|
+
smaller wins:
|
|
349
|
+
|
|
350
|
+
- `--ui-dropdown-cap` is what the consumer asked for. Unset, a panel is capped at
|
|
351
|
+
`--ui-dropdown-max`, which is 300px, and the panel stops there in the middle of a row. A plain list
|
|
352
|
+
shows 7 rows and half of the eighth. A list with a description line under each label shows 4 and a
|
|
353
|
+
half. A search panel shows 5 and a half, and 3 and a half with descriptions. The cut row tells the
|
|
354
|
+
reader that the list goes on, where a cap that ended on a whole label would look complete. The stop
|
|
355
|
+
is taken against the height the panel gets, which is the smaller of the cap and the room, so a
|
|
356
|
+
panel that the room limits is cut through a row too. In a body, the stop can spend some of the
|
|
357
|
+
room under the panel to reach the next half row instead of stopping a whole row short.
|
|
358
|
+
`scroll: true` is `.is-scroll`, which asks for that standard cap by name; `scroll: <n>` writes it
|
|
359
|
+
inline, as the property and not `max-height`, because an inline height would outrank the panel's
|
|
360
|
+
own `min()` and put it back past the edge. A cap you ask for is kept to its number and is not cut.
|
|
361
|
+
With `search`, it is the list's height, and the panel is the list and the search field over it.
|
|
362
|
+
- `--ui-dropdown-avail` is the measured room. The wiring writes it when a panel opens, or is already
|
|
363
|
+
open when the wiring attaches, and again on a resize. A portalled or lifted panel follows its
|
|
364
|
+
trigger, so it is measured again on a scroll too. The room comes from `dropdownAvail()` in `src/logic/dropdown.js` — one calculation, so the vanilla wiring
|
|
365
|
+
and the React `<Dropdown>` cannot disagree about where an open panel ends. `dropdownHeightFit(dd,
|
|
366
|
+
panel)` is that calculation, published so a second implementation can read it instead of measuring
|
|
367
|
+
its own. A closed panel carries no measured room: `--ui-dropdown-avail` stays unwritten, and the
|
|
368
|
+
sheet's fallback, `calc(100dvh - 2 * var(--ui-dropdown-edge))`, is the viewport's height, not the
|
|
369
|
+
trigger-to-edge room this section promises. A closed panel's height is outside this guarantee;
|
|
370
|
+
sizing one is [#501](https://github.com/apliteni/apliteni-ui/issues/501).
|
|
371
|
+
|
|
372
|
+
A panel with fewer rows than the cap keeps its content height. A panel is never taller than the cap,
|
|
373
|
+
also where the room is below the floor, as the next paragraph says. An open panel keeps the height
|
|
374
|
+
it opened at while the reader scrolls the page or the body, until the page is resized or the panel
|
|
375
|
+
opens again, so it does not grow or shrink under the reader. On a page, the room the panel keeps
|
|
376
|
+
under itself is the 8px edge, so opening a panel on a page that does not scroll adds no scroll.
|
|
377
|
+
|
|
378
|
+
A trigger near the edge can leave less room than `--ui-dropdown-min` (120px) wants for a usable
|
|
379
|
+
panel. The floor spends the edge inset, down to nothing, to try to reach 120px, but it never spends
|
|
380
|
+
room past the edge, because that room does not exist. Where even the whole inset falls short of
|
|
381
|
+
120px, an ordinary panel keeps its configured side and its cap, and can grow the page so the reader
|
|
382
|
+
can scroll to the rows past the fold. The wheel over such a panel carries on to the page once the
|
|
383
|
+
panel has reached its own end.
|
|
384
|
+
**A portalled panel flips when its configured side cannot hold the required height and the opposite
|
|
385
|
+
side has more room.** The required height is the floor, or the content height when shorter.
|
|
386
|
+
A smaller consumer cap can reduce that required height. The panel keeps its trigger gap and its resolved side through the close
|
|
387
|
+
animation. It restores the configured side when space returns. If neither side has enough room,
|
|
388
|
+
the roomier side can still extend beyond the viewport. A search panel is a column, so this cap
|
|
389
|
+
lands on the rows and not on the field: `.ui-dropdown__list` shrinks to whatever room the capped panel leaves it.
|
|
390
|
+
|
|
391
|
+
**A panel keeps its place while the page moves its trigger.** A row that re-lays itself out, an
|
|
392
|
+
ancestor scrolling sideways, a longer run of text beside the trigger, and a transition that slides
|
|
393
|
+
the trigger are each followed, closed as well as open. A transition is followed to where it stops
|
|
394
|
+
and not through the frames on the way, so a page that moves a trigger every frame has to reopen the
|
|
395
|
+
panel. A trigger scrolled out of the view keeps its panel at the view's edge rather than carrying it
|
|
396
|
+
off the screen.
|
|
397
|
+
|
|
398
|
+
`dropdownViewportFit(panel)` is published, so a second implementation of this dropdown can use the
|
|
399
|
+
kit's numbers instead of measuring its own. It answers nothing for a panel inside a filter bar,
|
|
400
|
+
whose row bounds it already — see [A filter row holds its panels](#a-filter-row-holds-its-panels).
|
|
401
|
+
What you give up is two promises worth less than the panel: that `align` is obeyed on a screen too
|
|
402
|
+
narrow to obey it, and that a panel is as wide as its widest row.
|
|
403
|
+
|
|
404
|
+
### A menu panel does not cut off its rows' ring
|
|
405
|
+
|
|
406
|
+
The ring appears outside the border box of the focused element. It has a one-pixel gap and a
|
|
407
|
+
two-pixel band. A row that reaches the panel edges draws the ring on the panel border and
|
|
408
|
+
outside it. The panel has only two choices: **keep the three pixels inside the panel as padding,
|
|
409
|
+
so the ring appears in the padding; or do not clip at the panel edge, so the ring crosses it.**
|
|
410
|
+
If the panel does neither, it cuts off the ring and leaves the reader with two accent bars.
|
|
411
|
+
`.ui-dropdown__panel` uses the first choice. The account menu uses the second, so its ring
|
|
412
|
+
extends two pixels beyond the panel border. This is accepted.
|
|
413
|
+
|
|
414
|
+
### A filter row holds its panels
|
|
415
|
+
|
|
416
|
+
**At any viewport a filter bar's panels add nothing to the page's scrollable width, and each
|
|
417
|
+
panel opens inside the row that holds it.** A chip's panel is as wide as its trigger. It is
|
|
418
|
+
bounded by its containing block. It therefore needs no measuring or JavaScript. Vanilla and
|
|
419
|
+
React use the same rule. The rule also breaks a long key or URL in the middle of a token instead
|
|
420
|
+
of letting it run beyond the page. The tradeoff is a narrower panel. A list that needs more room
|
|
421
|
+
should use a dropdown instead of a filter. The bound does not work with an inline `min-width`.
|
|
422
|
+
A chip also cannot become narrower than the selected value's min-content width.
|
|
423
|
+
|
|
424
|
+
**An open menu is wide enough to read.** A chip's trigger is only as wide as the value it shows.
|
|
425
|
+
When open, the menu uses the kit's 240px menu floor instead of the trigger's width. If its row is
|
|
426
|
+
narrower, it uses the row's width. When the side where it opens is short, it moves back along the
|
|
427
|
+
row. It never leaves the row or makes the page wider. When closed, the menu keeps the trigger's
|
|
428
|
+
width. This prevents the page from growing before any script runs. The floor is measured after
|
|
429
|
+
the kit's JavaScript runs. It is measured again when the row changes width or the chip moves
|
|
430
|
+
along the row. The width remains held until the menu finishes fading out. Nothing is painted
|
|
431
|
+
narrower than the row allows. `filterPanelFit(dropdown, floor)` and `DD_MENU_FLOOR` are
|
|
432
|
+
published. A second implementation can use the kit's numbers instead of measuring them again.
|
|
433
|
+
A dropdown composed against the row, rather than against a chip, owns its width. The row already
|
|
434
|
+
bounds it. The kit leaves it unchanged. This dropdown must not read the
|
|
435
|
+
`--ui-filter-panel-*` properties.
|
|
436
|
+
|
|
437
|
+
**A menu may ask for a wider floor than a chip's.** A chip's menu holds one chip's values; a
|
|
438
|
+
catalogue menu with a search field over it needs more room than the 240px floor leaves. Such a
|
|
439
|
+
panel declares `--ui-filter-panel-ask` in the stylesheet, which is also what makes a menu outside
|
|
440
|
+
a chip a subject of the fit: it is then `--panel-sm` wide where its row has the room and its row's
|
|
441
|
+
width where it does not. `filterPanelRow(dropdown)` is published. It answers which
|
|
442
|
+
`.ui-filter-bar` a menu's fit is measured inside — a chip's menu, or a menu that asks for a
|
|
443
|
+
width — and `null` for anything else, so both faces decide which menus they re-fit and hold
|
|
444
|
+
from one calculation.
|
|
445
|
+
|
|
446
|
+
**The menu marks the value the chip is showing.** The active row receives a soft accent wash and
|
|
447
|
+
keeps the kit's 16px check. The wash is a tint. Its contrast is 1.16:1 over the panel in light
|
|
448
|
+
mode and 1.20:1 in dark mode. The check identifies the chosen row: its contrast is 6.35:1 over
|
|
449
|
+
the wash in light mode and 4.13:1 in dark mode. Hover makes the wash darker instead of adding an
|
|
450
|
+
outline: 9% more accent, which reads 1.15:1 off the resting wash in light and 1.14:1 in dark. The
|
|
451
|
+
wash remains under focus, which would otherwise paint an opaque fill over it; focus reads by the
|
|
452
|
+
band instead. **The arrow keys are not a third state here.** A filter chip's panel carries no
|
|
453
|
+
search field, and without one a dropdown marks no active row, so what an arrow key moves in this
|
|
454
|
+
bar is real focus: the row keeps its wash and its check and takes the band over them.
|
|
455
|
+
`filterChipItems(filter)` chooses the row. It gives the menu the chip's items and marks the
|
|
456
|
+
chip's own value. It matches a row by its `value`, or by its `label` when it has no `value`.
|
|
457
|
+
Both faces call it. The text printed by the chip and the row marked by the menu therefore use the
|
|
458
|
+
same value, and you receive the mark without setting it yourself. A chip with no chosen value,
|
|
459
|
+
or with a value that matches no row, marks nothing. A `selected` value you set does not replace a
|
|
460
|
+
value that the bar is not applying. The kit never writes to your own array or objects.
|
|
461
|
+
|
|
462
|
+
**The clear action is offered only when there is something to clear.** React `FilterBar`
|
|
463
|
+
renders it after a filter has a value. It uses the kit's ghost button without a fill
|
|
464
|
+
or border. A consumer reading `[data-filter-clear]` finds nothing when no filter has a value.
|
|
465
|
+
Both faces label it `Clear all`; `clearLabel` takes any wording.
|
|
466
|
+
**React `FilterBar` draws the remove mark only on a chip with a value.** A chip with no value has
|
|
467
|
+
nothing to remove. If the mark has focus when it goes, focus moves to that chip's trigger.
|
|
468
|
+
|
|
469
|
+
**Filter labels use secondary-control ink and weight.** The remove mark uses glyph ink.
|
|
470
|
+
A chip keeps its quiet edge when hovered or open. The add control moves its edge to the accent
|
|
471
|
+
under the pointer, the way every trigger in the kit does, and steps that edge aside while it
|
|
472
|
+
holds the focus ring. Clear keeps no edge in any state and answers the pointer with the accent
|
|
473
|
+
wash the kit's buttons hover with. A control that is disabled or busy answers the pointer with
|
|
474
|
+
nothing. Keyboard focus draws the shared `--ring`. A disabled chip or add control takes
|
|
475
|
+
`--disabled-border`. The add and clear controls carry no resting fill.
|
|
476
|
+
|
|
477
|
+
**An emptied bar hands the focus on rather than keeping it.** When you clear the last filter or
|
|
478
|
+
remove the last chip with the keyboard, the focused control disappears. The bar moves focus to
|
|
479
|
+
the way to add a filter where the row still draws one — that control outlives the chips, so an
|
|
480
|
+
emptied row is not an empty row — then to the control that a reader would reach with the next
|
|
481
|
+
<kbd>Tab</kbd>. It skips controls the reader cannot reach: being reachable is not the same as
|
|
482
|
+
taking the focus, so each candidate is asked and then checked. If nothing beside the bar can take
|
|
483
|
+
focus, the focus stays where it is.
|
|
484
|
+
`nextFocusStop(host)` identifies that control. `focusNextStop(host)` moves focus there and returns
|
|
485
|
+
the element that received it. A consumer that wants to move focus itself can read the same result.
|
|
486
|
+
|
|
487
|
+
**A React bar given `add` and `onAdd` draws its own way to add one.** The control sits on the
|
|
488
|
+
chips' line, after them and before the clear action, so <kbd>Tab</kbd> reaches it where it is
|
|
489
|
+
drawn. Its menu holds one section per filter the bar is not already carrying, so no pick can put
|
|
490
|
+
a second chip under one id, and takes a search field at ten values. A pick asks you for that
|
|
491
|
+
filter and nothing else; answer it in the same update and focus lands on the new chip, answer it
|
|
492
|
+
later and you own where focus goes. <kbd>Esc</kbd> closes the menu and adds nothing. The control
|
|
493
|
+
is drawn only while something is left to add, and it stands at a chip's height and corner. It is
|
|
494
|
+
labelled `Filter`, for the reason the clear action is labelled `Clear all`; `addLabel` takes any
|
|
495
|
+
wording. The vanilla `filterBar()` has no `add`, so a vanilla page draws its own control and the
|
|
496
|
+
kit answers it through markup: put your own `dropdown()` inside the bar, wrapped in an element
|
|
497
|
+
carrying `data-filter-add`. That attribute is the whole contract — it declares the ask, carries
|
|
498
|
+
the open rule's room, slide and closing hold, gives the trigger the chip's corner, height and
|
|
499
|
+
edge, and is what the focus answer looks for. A pick inside it is yours to act on: the bar
|
|
500
|
+
reports a change for a chip's menu and for nothing else. `initFilterBar()`'s `update()`
|
|
501
|
+
rebuilds the bar from `filterBar()`, which draws no such control, so keep your wrapper in the
|
|
502
|
+
DOM yourself. The Stock screener showcase draws one.
|
|
503
|
+
|
|
504
|
+
### A dropdown row is a div, a link or a button
|
|
505
|
+
|
|
506
|
+
`.ui-dropdown__item` looks the same with all three tags. You decide which tag represents each
|
|
507
|
+
row. The kit does not decide for you. The rule removes the browser's button styling and uses
|
|
508
|
+
`font: inherit` for the `font` shorthand. This also keeps a portalled panel from taking its
|
|
509
|
+
typeface from the place where it was mounted. `dropdown()` emits a `<div>`, or an `<a>` when an
|
|
510
|
+
item has `href`. It never emits a `<button>`. A row that must be a real button is
|
|
511
|
+
[one you write yourself](#a-dropdown-row-you-write-yourself). **A destructive row stays quiet
|
|
512
|
+
and turns `--pink` on the way to being pressed**, in both hover and focus.
|
|
513
|
+
|
|
514
|
+
### A submenu row
|
|
515
|
+
|
|
516
|
+
A row that opens a submenu carries `aria-haspopup="menu"` and `aria-expanded`. It ends in
|
|
517
|
+
`.ui-dropdown__aside`, the current value in small full ink, and `.ui-dropdown__more`, a
|
|
518
|
+
`chevronRight` glyph. While its submenu is open the row keeps the hover fill. The submenu is a
|
|
519
|
+
`role="menu"` list in `.ui-dropdown__sub` with `menuitemradio` rows, and `.ui-dropdown__tick`
|
|
520
|
+
marks the chosen one. Where the menu is clipped, as in a sidebar, put the list in a
|
|
521
|
+
`.ui-dropdown__panel.ui-dropdown__panel--portal.ui-dropdown__panel--sub.is-open` on `body`,
|
|
522
|
+
level with the row. On a phone, put it inside the menu panel and add `is-sub` to the panel:
|
|
523
|
+
every child but `.ui-dropdown__sub` is hidden, so the list replaces the rows. Start that list
|
|
524
|
+
with a back row. Right and Enter open the submenu, Left and Escape close it, and focus returns
|
|
525
|
+
to the row. The vanilla kit ships the classes, and React `AppShell`'s Theme row wires the keys
|
|
526
|
+
(`react/src/AccountMenu.tsx:18` `function AccountMenu`).
|
|
527
|
+
|
|
528
|
+
### Avatar
|
|
529
|
+
|
|
530
|
+
`avatar()` draws a person as a filled circle with their first and last initials. It is 24 px, or
|
|
531
|
+
32 px with `size: 32`. **The hue comes from `key`**, the app's stable id for the person, so one person
|
|
532
|
+
keeps one hue on every screen. A hash of the key picks one of eight fixed hues, and the letter ink
|
|
533
|
+
is chosen to read on each one in both themes and under every accent. A name with no letters draws
|
|
534
|
+
the `user` glyph. `empty: true` draws a dashed ring for "no one". **A `src` photo covers the
|
|
535
|
+
letters**, and the letters show when the photo does not load. **The mark is hidden from assistive
|
|
536
|
+
technology**, because the person's name always stands beside it. It has no hover, focus or cursor
|
|
537
|
+
of its own: a button that holds it keeps its own. In React it is `<Avatar personKey name src size
|
|
538
|
+
empty />`. A `dropdown()` item takes `avatar: { key, name, src }` and draws it in the leading slot.
|
|
539
|
+
A `select` leads its trigger with the chosen row's mark, and with no value it shows the dashed ring
|
|
540
|
+
and the placeholder. The top bar account button, the menu it opens and the shell's reader block draw the same mark, in the same hue.
|
|
541
|
+
|
|
542
|
+
### A dropdown with a search field
|
|
543
|
+
|
|
544
|
+
`search: true` adds a text field above a dropdown's rows. It filters the rows as the reader types.
|
|
545
|
+
This is opt-in. A dropdown without it renders as before. **Typing filters, and focus stays in the
|
|
546
|
+
field**, which has `role="combobox"` over the list. `aria-activedescendant` names the row that
|
|
547
|
+
Enter would pick. The field carries the focus ring. The active row is marked by the hover fill
|
|
548
|
+
alone — an edge around a row would be the focus band's own shape. **The match is anywhere in the label**, with case and accents ignored. Rows keep their
|
|
549
|
+
original order. Descriptions are not searched, so put the words a reader will type in the label.
|
|
550
|
+
**`count` names the size of the set** in the placeholder and in the field's accessible name, for
|
|
551
|
+
example "Search 214 people", and `noun` changes the word. A placeholder or label you write wins. A
|
|
552
|
+
`select` dropdown inside a `field()` takes the field's width, and its panel takes the trigger's.
|
|
553
|
+
**Every open starts from the whole list**, and a query with no matches says so instead of showing
|
|
554
|
+
an empty panel. **The panel is a dialog**, because a listbox may own only options. When a dropdown
|
|
555
|
+
must have a search field is a rule rather than a recommendation:
|
|
556
|
+
[Component choice](../guidelines/component-choice.md).
|
|
557
|
+
|
|
558
|
+
### The drawer
|
|
559
|
+
|
|
560
|
+
A drawer is a panel against one edge of the screen. It appears over a scrim. It lets the reader
|
|
561
|
+
look at or change one thing without leaving the list that opened it. **It groups by heading, never
|
|
562
|
+
by card:** `drawerSection()` puts a heading above a `<dl>` of label and value pairs. A screen reader
|
|
563
|
+
then hears each label with its value. The value stays beside its label instead of moving to the far
|
|
564
|
+
edge of the panel. A row whose value is a field or a dropdown lines its label up with the control's first line of text.
|
|
565
|
+
This alignment happens by itself. There is no setting for it.
|
|
566
|
+
Nothing inside a drawer draws a card, a row rule or an `<hr>`. Actions stay
|
|
567
|
+
outside the scrolling body. **It moves on open and on close**, and both movements are instant when
|
|
568
|
+
reduced motion is enabled. For when a flow should use a drawer or a page:
|
|
569
|
+
[Drawer](../guidelines/drawer.md).
|
|
570
|
+
|
|
571
|
+
### The modal
|
|
572
|
+
|
|
573
|
+
The React `Modal` limits its height to 96% of the dynamic viewport. Its body scrolls, while its
|
|
574
|
+
title, close control and footer stay visible. It is a borderless raised surface. It uses the drop
|
|
575
|
+
alone, `--radius-md`, a `--text-base` title and a deep scrim without blur. It names itself with an
|
|
576
|
+
`h2`. The HTML entry point ships no general modal. Its separate `confirm()` is unchanged.
|
|
577
|
+
|
|
578
|
+
### The account window
|
|
579
|
+
|
|
580
|
+
The React `AccountWindow` is the account and settings window. The product gives it the reader
|
|
581
|
+
and the sections, each with its id, label, icon and content. The window draws the rest: the
|
|
582
|
+
dimmed page, the close, the section title and the rail. It is 1024px wide and 76% of the
|
|
583
|
+
viewport high, with a 216px rail. It narrows to 96% of a smaller screen, and it keeps 32px
|
|
584
|
+
above and below it on a short one. The rail is the page ground, with the reader's avatar, name
|
|
585
|
+
and email at its top. Only the open section's row carries the accent. Each rail row is a button
|
|
586
|
+
with `aria-current`, because a section is a place in the window and not a route. The pane remounts
|
|
587
|
+
when the section changes, so a half-filled form does not follow the reader. At 560px and below
|
|
588
|
+
the window fills the screen, and the sections become tabs under the reader. They act as the
|
|
589
|
+
`Tabs` panel tabs do: one Tab stop, the arrow keys, Home and End, and the open tab scrolled into
|
|
590
|
+
view. Pass `section` and `onSectionChange` to control the open section, or `defaultSection` to
|
|
591
|
+
leave it to the window.
|
|
592
|
+
|
|
593
|
+
### The hover readout
|
|
594
|
+
|
|
595
|
+
`tooltip()` is the readout that a surface shows while a pointer rests on one of its marks. It is an
|
|
596
|
+
overlay. That is the guarantee: **showing, filling or moving a readout never changes the size or
|
|
597
|
+
the place of anything else on the page.** There is one element per host. It is placed absolutely
|
|
598
|
+
and takes no pointer events. `.ui-tip-host` marks the box it is placed against. The readout flips
|
|
599
|
+
or slides only as far as needed to stay inside the viewport and every ancestor whose overflow
|
|
600
|
+
clips. **What it says is text**, written with `textContent` and never parsed. Focus on a mark shows
|
|
601
|
+
the readout and describes the mark through `aria-describedby`. **Escape dismisses every readout
|
|
602
|
+
the kit is showing**. **Under a coarse pointer the tap is the switch**, and the opening tap is
|
|
603
|
+
captured. This means a chart that drills down on a bar does not drill down on the tap that asked
|
|
604
|
+
what the bar says. No value may be reachable only by hovering. See
|
|
605
|
+
[Hover readouts](../guidelines/hover-readouts.md).
|
|
606
|
+
|
|
607
|
+
### The React tooltip
|
|
608
|
+
|
|
609
|
+
React `Tooltip` shows a label, a value and an optional detail.
|
|
610
|
+
`text` is still a shorthand for `label`. Empty parts are hidden.
|
|
611
|
+
The focusable trigger provides the readout as its accessible description. Escape keeps focus on the trigger.
|
|
612
|
+
The panel does not change the layout or intercept pointer events. Reduced motion removes the fade.
|
|
613
|
+
|
|
614
|
+
`placement` selects the preferred top or bottom side. The readout stays within clipping ancestors
|
|
615
|
+
and viewport bounds, and updates its position on scroll and resize.
|
|
616
|
+
|
|
617
|
+
### Pagination
|
|
618
|
+
|
|
619
|
+
The pager renders a page you have already computed. It uses the current page, the page size and,
|
|
620
|
+
where you know it, the total. A page counted by a server and a page sliced from an array therefore
|
|
621
|
+
produce the same markup. **A result whose size is not known is a supported shape, not a degraded
|
|
622
|
+
one:** without a total, the pager offers the step before and the step after. It does not claim a
|
|
623
|
+
page count. **A control that would leave the result is disabled and stays where it is**. It is
|
|
624
|
+
never removed or replaced with text. **One page of content gets no steps.** **The row range is
|
|
625
|
+
announced**, politely and as one whole message. It is the only part of the pager that announces.
|
|
626
|
+
**The page size is a scale the kit names**. You choose which sizes a table offers and whether to
|
|
627
|
+
remember the reader's choice. **A page turn does not move the ground under the reader:** the
|
|
628
|
+
pager keeps its numbers legible, marks itself busy and stops accepting input while the next page
|
|
629
|
+
loads.
|
|
630
|
+
|
|
631
|
+
### Stat bands
|
|
632
|
+
|
|
633
|
+
`statBand()` renders a row of key figures as a description list. A screen reader can then read each
|
|
634
|
+
figure as one statement. **A figure's value is never broken across lines and never truncated;**
|
|
635
|
+
the words below it give way instead. A band that is too narrow for its figures folds before normal
|
|
636
|
+
wrapping would leave one figure alone on a row. It decides this from **its own width**, not the
|
|
637
|
+
window's. In a flex row or an `auto` grid track, you give it one:
|
|
638
|
+
|
|
639
|
+
| Layout | Four fold two by two at | An odd count stacks at | One column at | Smaller value below |
|
|
640
|
+
|---|---|---|---|---|
|
|
641
|
+
| Band and tiles | 56rem | 42rem | 28rem | 14rem |
|
|
642
|
+
| Open | 66rem | 50rem | 32rem | 15rem |
|
|
643
|
+
|
|
644
|
+
Below 14rem, band and tile values use the next smaller type rank. Open values step down below 15rem.
|
|
645
|
+
Longer values remain the caller's responsibility.
|
|
646
|
+
|
|
647
|
+
A band can use `basisId` to reference comparison text before the figures. An explicit `basis` takes precedence.
|
|
648
|
+
When a period control already states the window, omit a caption that repeats it, including for totals without changes.
|
|
649
|
+
|
|
650
|
+
**A change shows which way it went with an arrow read off the sign you printed**, and colour follows
|
|
651
|
+
your verdict alone. No tone and `neutral` are the same neutral change. **A figure with nothing to
|
|
652
|
+
compare draws no row at all:** never `+0%`, and never a sentence saying there is nothing to say.
|
|
653
|
+
**A change says what it is measured against, in text a reader can reach**. Put it once for the band
|
|
654
|
+
in its caption, or beside the change when one figure is measured against something else. A hover
|
|
655
|
+
`title` does not count. **The caption comes before the figures**, as a table's `<caption>` does.
|
|
656
|
+
**A figure says at most one thing under its value, and it says it in one row**. A caption earns that
|
|
657
|
+
row only by giving a unit, a period or a limit that the figure cannot. **The trend is a slot:** the
|
|
658
|
+
kit sizes and colours your `<svg>` and draws no chart. Three layouts ship. `tiles`, the default,
|
|
659
|
+
puts each figure on its own card. `band` is one card. `open` draws no surface and sets the value
|
|
660
|
+
larger.
|
|
661
|
+
|
|
662
|
+
### Dense financial tables
|
|
663
|
+
|
|
664
|
+
The table is markup. A named scroll region contains a native `<table>`, and you apply the
|
|
665
|
+
recipes as classes. Zebra adds no grey stripes. Hover gives a row a quiet neutral fill.
|
|
666
|
+
Keyboard focus keeps its ring, and a landed row keeps its own mark. `compact` sets a 33px minimum row, but larger or wrapped content makes the row
|
|
667
|
+
taller. **Columns scroll rather than disappear**, while sticky headers and pinned identity cells
|
|
668
|
+
keep opaque backgrounds, the shared focus composition, and their full accessible names. **A
|
|
669
|
+
pinned column draws its divider only where the region can actually scroll:** at a width where
|
|
670
|
+
every column fits, the line divides nothing, so it is not drawn. **The region shows a soft shade
|
|
671
|
+
on whichever edge still has columns behind it, and none on an edge that has been reached** —
|
|
672
|
+
darker on a light ground, lighter on a dark one. Both are CSS alone, so vanilla and React tables
|
|
673
|
+
carry them alike, and neither reaches the focus ring. An engine that cannot report a scroll state
|
|
674
|
+
keeps the divider at every width. **A link
|
|
675
|
+
inside a cell uses the row's ink, gets an underline on hover, and uses the shared ring on
|
|
676
|
+
`:focus-visible`**. The ring surrounds the whole link, including a title-cell link that wraps.
|
|
677
|
+
`numericValue` distinguishes missing from zero. `deltaValue` prints your sign and uses your
|
|
678
|
+
explicit judgement. **Colour never supplies the sign.**
|
|
679
|
+
|
|
680
|
+
A cell can group its reference and status with `.ui-table__pair`. They stack when the cell cannot fit them side by side.
|
|
681
|
+
A landed row's `.is-target` mark shows on pointer arrival as well as keyboard focus, and it outlives focus, so arrival and focus show together and stay distinguishable.
|
|
682
|
+
The caller brings the target row into view and keeps its mark until the next arrival.
|
|
683
|
+
|
|
684
|
+
**A cell marked `.ui-table__linked` holds one link and nothing else, and the kit then gives that
|
|
685
|
+
link the whole cell.** The focus ring and the pointer target become the cell rather than the two
|
|
686
|
+
words inside it, and the ring there is the inward band. The cell hands its padding over, so
|
|
687
|
+
nothing on the page moves and no row changes height. Mark the cell yourself: a cell reading
|
|
688
|
+
`Invoice 1162` with the number linked looks the same to a stylesheet, and filling that one would
|
|
689
|
+
put the number on a line of its own. A marked cell holding anything else keeps the plain link box.
|
|
690
|
+
**Every other anchor the kit styles keeps the box, the corner and the paint its own component
|
|
691
|
+
sets**, marked cell or not: `.ui-btn`, and a `.ui-dropdown__item`, or `.ui-nav__item`
|
|
692
|
+
composed into a cell.
|
|
693
|
+
|
|
694
|
+
**Below 720px a pinned identity cell keeps its content on one line**, capped at
|
|
695
|
+
`--ui-table-identity-max` and cut with an ellipsis past the cap. The default cap is
|
|
696
|
+
`min(var(--panel-sm), 50vw)`, and that one property is yours to retune. The whole text stays in
|
|
697
|
+
the markup, so the accessible name is unchanged and the company link remains the disclosure. The
|
|
698
|
+
decorative logo is not drawn there. A sub-line stays running text, which is a rule in
|
|
699
|
+
[Dense tables](../guidelines/dense-tables.md). **Focusing a link inside a sub-line draws the band
|
|
700
|
+
around the whole line**, because the cell clips and a band around the link alone could not close
|
|
701
|
+
its right side.
|
|
702
|
+
|
|
703
|
+
**On a phone, a table stays a table.** No kit table lays its rows out as blocks. A table wider
|
|
704
|
+
than the screen scrolls sideways inside its frame, and the page does not scroll. A pinned identity
|
|
705
|
+
column stays at the frame's left edge on the table's own surface, so it follows the theme. While
|
|
706
|
+
columns sit under it, a soft shade from the edge token falls to its right. At the left edge there
|
|
707
|
+
is no shade. This is a rule in [Dense tables](../guidelines/dense-tables.md).
|
|
708
|
+
|
|
709
|
+
`FilterBar` is controlled by you. Selections, removal, and clear-all request changes. They never
|
|
710
|
+
change the filters you supplied. Given `add` and `onAdd` it also draws the way to add one; see
|
|
711
|
+
[A filter row holds its panels](#a-filter-row-holds-its-panels). **A chip shows only the chosen value**, while the field's name
|
|
712
|
+
appears only when nothing is chosen. Next to a value, the name reaches the reader through the
|
|
713
|
+
trigger's accessible name and a hidden legend.
|
|
714
|
+
|
|
715
|
+
### The command palette
|
|
716
|
+
|
|
717
|
+
The kit provides the palette shell, its ranking, and its keyboard. It does not name result kinds.
|
|
718
|
+
What a result *is* — an invoice, a campaign, or a domain — comes from your product's vocabulary.
|
|
719
|
+
The groups also come from your product. **A row can behave in three ways**, because Enter must
|
|
720
|
+
give a different result in each case. A row that goes somewhere has an `href`. A row that runs
|
|
721
|
+
something reports a `ui-command` event. A row that destroys something names a confirm and opens
|
|
722
|
+
it. **A destructive row with no confirm is rendered disabled instead of running.**
|
|
723
|
+
|
|
724
|
+
**A same-tab pick can go through a client router.** Give the palette `onNavigate`, and a
|
|
725
|
+
same-tab pick on an `href` row calls it with the href instead of setting `window.location.href`,
|
|
726
|
+
so the page changes without a reload. A Cmd- or Ctrl-held pick still opens the tab itself.
|
|
727
|
+
Without the prop, a same-tab pick navigates the way it always has.
|
|
728
|
+
|
|
729
|
+
```tsx
|
|
730
|
+
<CommandPalette open groups={groups} onClose={close} onNavigate={(href) => router.push(href)} />
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
**Results are ranked by how the query matches the item, and you break every tie.** A whole label
|
|
734
|
+
beats a prefix. A prefix beats a word start. A word start beats a substring. A keyword beats a
|
|
735
|
+
note. Initials come last. Groups use the score of their best row. Equal scores keep the order
|
|
736
|
+
you passed. The kit remembers nothing between openings, and **a palette fed by a server does not
|
|
737
|
+
rank results at all**: the client keeps the order it was handed, and the ranking above becomes
|
|
738
|
+
the server's to apply — with `rankGroups`, the exported function both faces use, rather than a
|
|
739
|
+
second one written beside it, so a list drawn on a server and the same list after a keystroke
|
|
740
|
+
cannot disagree about what comes first. **The keyboard is these keys and no others.** Cmd or
|
|
741
|
+
Ctrl+K opens the palette, the arrows move the active row and wrap at both ends, Enter runs it,
|
|
742
|
+
and Escape closes the top overlay. Tab is trapped in the panel. Home and End stay with the text
|
|
743
|
+
caret, which is what the ARIA combobox pattern gives them for, and Ctrl+K inside another text
|
|
744
|
+
box is left alone, because it is kill-to-end-of-line there — Cmd+K still opens from one.
|
|
745
|
+
**Focus opens in the text box and never leaves it while the palette is open**, over an inert page.
|
|
746
|
+
The search row shows the accent ring inside its edges while the text box has keyboard focus, and its divider hides under the ring.
|
|
747
|
+
**It opens empty**, and **it paints one step above the drawer and one below the confirm**. A
|
|
748
|
+
confirm opened by a row appears over both and answers the first Escape.
|
|
749
|
+
|
|
750
|
+
### Success confirmations
|
|
751
|
+
|
|
752
|
+
A confirmation has **one title and at most one short line below it**. It has no eyebrow:
|
|
753
|
+
`success()`, `<Success>`, and `successPanel()` take a title and one detail line. Nothing adds a
|
|
754
|
+
third tier above or between them. They draw the confirmation on a plain elevated card. The card
|
|
755
|
+
uses the kit surface and its border, with nothing behind it. There is no backdrop layer and no
|
|
756
|
+
`backdrop` option. The mark is one of two, selected with `check`:
|
|
757
|
+
|
|
758
|
+
| `check` | Mark | Size | Motion |
|
|
759
|
+
| --- | --- | --- | --- |
|
|
760
|
+
| `line` (default) | Lucide `check`, bare, in the success colour | 56px hero, 72px split, 28px compact, 28px inline panel | strokes itself on over `--dur-slow` |
|
|
761
|
+
| `circled` | Lucide `circle-check-big` (the kit's `circleCheck`) | 20px, the kit's label size — every layout, inline panel included | at rest |
|
|
762
|
+
|
|
763
|
+
`line` uses the size for the layout where it appears. `circled` uses one size everywhere. Both
|
|
764
|
+
are unmodified Lucide paths in a 24 box. Neither has a filled disc or a burst ring behind it.
|
|
765
|
+
[Iconography](../guidelines/iconography.md) reserves a circled glyph for a state, so `circled`
|
|
766
|
+
is the mark that rule requires. `line` is the default because it carries the moment at page
|
|
767
|
+
size. An action that is not a kit `Button` — a router link or a plain `<a>` — is ringed already and
|
|
768
|
+
needs no class; `.ui-focusable` is for a focusable that is neither a link nor a kit control.
|
|
769
|
+
|
|
770
|
+
`callout()` uses the same status split as toasts. Success, danger and warning use
|
|
771
|
+
`circleCheck`, `circleX` and `circleAlert`. Info and neutral callouts use `info`. A caller can
|
|
772
|
+
still pass `icon` when the tone does not say enough.
|
|
773
|
+
|
|
774
|
+
### Pending and denied states
|
|
775
|
+
|
|
776
|
+
Every screen has two states: it is still fetching, and the reader is not allowed to see it.
|
|
777
|
+
**One region has three renders:** `busyRegion()` is a live region that *outlives* what it
|
|
778
|
+
reports on. It first renders with a skeleton inside. `setBusy()` then replaces its body and
|
|
779
|
+
writes a line into the screen-reader node that the region already contains. A live region whose
|
|
780
|
+
text changes is the only thing assistive technology reliably speaks. It reuses the pair
|
|
781
|
+
`toast()` and `success()` carry. There is no second mechanism. A skeleton is `aria-hidden`.
|
|
782
|
+
**`deniedState()` has no role of its own**, so the region where you place it announces it. It does
|
|
783
|
+
not need to announce itself as a whole page. There is **no spinner factory**. At screen scale, a
|
|
784
|
+
skeleton shows what shape is coming.
|
|
785
|
+
|
|
786
|
+
```js
|
|
787
|
+
const el = document.querySelector('#report');
|
|
788
|
+
el.innerHTML = busyRegion({ label: 'Loading your report…', lines: 4 });
|
|
789
|
+
const rows = await fetch(…);
|
|
790
|
+
setBusy(el, { busy: false, message: `${rows.length} rows`, body: table(rows) });
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
### Busy button labels
|
|
794
|
+
|
|
795
|
+
A busy button replaces its visible label with three centred pulsing dots in the variant's full
|
|
796
|
+
label ink. The brightest dot clears 3:1 against every variant fill in both themes. Text does not
|
|
797
|
+
fade or blink. The retained label and icons keep the button's dimensions stable. Reduced motion
|
|
798
|
+
switches directly between the label and static dots. **A wired busy button keeps focus:**
|
|
799
|
+
`aria-disabled` communicates the state. Click, Enter and Space activation are blocked. Both faces
|
|
800
|
+
announce through a status region outside `aria-busy`. This region stays through completion, so it
|
|
801
|
+
can announce both progress and completion. React takes `completionMessage` to word that
|
|
802
|
+
completion. Use `completionMessage=""` to say nothing when a form error or another live region
|
|
803
|
+
announces the outcome. An explicitly disabled button stays natively disabled. Unwired
|
|
804
|
+
`button({ busy: true })` markup keeps native disabled as a safe fallback.
|
|
805
|
+
|
|
806
|
+
### Extra-small buttons
|
|
807
|
+
|
|
808
|
+
`button({ size: 'xs' })` and React `<Button size="xs">` draw a 13px glyph at stroke-width 2.8.
|
|
809
|
+
They have a minimum 24×24px target. An icon-only xs button is 24×24px. A labelled button grows
|
|
810
|
+
to fit its label at `--text-xs`. Other sizes keep their 16px glyph at stroke-width 2.4. Busy
|
|
811
|
+
dots fit inside the smaller target. The size does not change the variant's colour or its
|
|
812
|
+
interaction states.
|
|
813
|
+
|
|
814
|
+
### Code highlighting
|
|
815
|
+
|
|
816
|
+
`hlCode(raw, lang)` returns highlighted HTML. `codeTokens(raw, lang)` returns the same tokens as
|
|
817
|
+
data. `hlShell(raw)` is the shell case under the name it has always had. `codeLanguages` lists
|
|
818
|
+
the values that `lang` accepts. An unrecognised name is read as shell. One tokenizer serves both
|
|
819
|
+
faces, so vanilla HTML and React spans cannot drift apart. The five classes carry different
|
|
820
|
+
meanings per language:
|
|
821
|
+
|
|
822
|
+
| Language | `.k` | `.s` | `.f` | `.u` | `.c` |
|
|
823
|
+
| --- | --- | --- | --- | --- | --- |
|
|
824
|
+
| `shell` | the command | a quoted string | a flag | a URL | a `#` comment |
|
|
825
|
+
| `json` | a property key | a string value | a number, `true`, `false`, `null` | — | — |
|
|
826
|
+
| `ts` | a keyword | a string or template | a number or literal | — | a `//` or `/* */` comment |
|
|
827
|
+
|
|
828
|
+
They colour short snippets, not arbitrary programs. Three of the five miss WCAG AA on the light
|
|
829
|
+
card. They are recorded as debt, not presented as compliant: `.f` and `.u` at 3.81:1 and `.s` at
|
|
830
|
+
4.45:1. **The copy button is icon-only in both faces**, with `copyLabel` as its accessible name
|
|
831
|
+
and `title`. **Confirming a copy does not change the control's size or its name**: the glyph
|
|
832
|
+
swaps inside the same box, and the word goes to a hidden live region. Snippet descendants use
|
|
833
|
+
the shared ring, except the browser-focusable code region. A `<pre>` sits flush with its card and
|
|
834
|
+
has no radius, so **the card paints that ring instead**.
|
|
835
|
+
|
|
836
|
+
### A toolbar at one column
|
|
837
|
+
|
|
838
|
+
A toolbar above a list opens with a search box, followed by its filters and then its view switch.
|
|
839
|
+
`.ui-toolbar` gives its text field a `6rem` flex basis. The row breaks only when the field would
|
|
840
|
+
be squeezed below that size. At `560px`, that basis would become the field's size rather than its
|
|
841
|
+
floor. So at that width the field uses `flex-basis: 100%`. It takes the full line, and the rest
|
|
842
|
+
of the row wraps below it.
|
|
843
|
+
|
|
844
|
+
A title without an introduction keeps a 32px gap before the page body.
|
|
845
|
+
A control row directly inside the body sits 8px closer to the block it controls.
|
|
846
|
+
Use `.ui-toolbar--split` to place the final control at the row's end. On a phone, it stays in that row beside the control before it, rather than dropping to its own line.
|
|
847
|
+
|
|
848
|
+
### Segmented strips that outgrow their column
|
|
849
|
+
|
|
850
|
+
The enabled selected pill uses an accent fill with contrasting label ink in both themes. A disabled selected pill keeps a quiet fill and disabled ink. Only keyboard focus draws an outline.
|
|
851
|
+
|
|
852
|
+
A pill strip lays out its choices in one row while they fit. When they do not fit, the choices
|
|
853
|
+
wrap onto further rows. **It never widens past its container:** a twelve-month picker in a phone
|
|
854
|
+
column becomes three rows of pills instead of pushing the page sideways. Below 560px, the
|
|
855
|
+
standard-size pills reduce their side padding while keeping the same type rank. The underline
|
|
856
|
+
appearance wraps too, so no tab is cut off at a phone width. A label that is too long for the
|
|
857
|
+
column wraps inside its own tab. Arrow keys, Home and End skip disabled choices.
|
|
858
|
+
|
|
859
|
+
### The chosen tab in an underline strip
|
|
860
|
+
|
|
861
|
+
The chosen tab is its own label with 2px of accent under it. It has no plate, hairline or upright
|
|
862
|
+
rail. **The accent is spent once.** No tab draws a visible box against the strip's ground. The
|
|
863
|
+
pill appearance marks its chosen button with a fill; the underline strip overrides that fill back
|
|
864
|
+
to `none`, because the bar under the label is its whole mark. It has no background, border or
|
|
865
|
+
inset shadow. Nothing in it reads as a card lying on the page. The
|
|
866
|
+
strip also draws no rule under its tabs. A consumer that wants one draws it on the container.
|
|
867
|
+
|
|
868
|
+
**Every mark that says "chosen" sits inside that tab's own box**, clear of its edges. This lets the
|
|
869
|
+
strip wrap. A tab on a further row carries its whole highlight with it and is never read against
|
|
870
|
+
the row above or below. Every tab reserves the bar, but only the chosen one draws it. The mark
|
|
871
|
+
therefore grows in place when the choice moves. Hover is an ink step from `--text` to
|
|
872
|
+
`--strong`, the step every kit tab takes. There is no second mark.
|
|
873
|
+
|
|
874
|
+
### A selected item in forced colours
|
|
875
|
+
|
|
876
|
+
In forced colours, selected items use Highlight and HighlightText, unavailable selections use GrayText, and focus rings use CanvasText.
|
|
877
|
+
|
|
878
|
+
### Escaping and URL slots
|
|
879
|
+
|
|
880
|
+
Factories return HTML strings. **Text and attribute values are escaped where written:** quotes and
|
|
881
|
+
angle brackets in a name, identifier, class modifier or label cannot add an attribute or an
|
|
882
|
+
element. Do not escape ordinary text or URL slots before passing them in. **URL slots reject
|
|
883
|
+
`javascript:`, `data:` and `vbscript:`**, case-insensitively. This includes leading ASCII
|
|
884
|
+
controls and embedded tabs or newlines. Other schemes, relative paths and fragments keep their
|
|
885
|
+
original values. A rejected navigation URL renders as `#`. A rejected image source renders as
|
|
886
|
+
an empty `src`. `backLink()` renders nothing at all for one.
|
|
887
|
+
|
|
888
|
+
**Slots documented as trusted HTML are not sanitized**, and their author owns the markup and any
|
|
889
|
+
URLs inside it. They are a card's `title`, `sub` and `body`; a callout's `body` and `actions`; a
|
|
890
|
+
drawer's `body` and `footer` and a drawer section's `body` and row `value.html`; a dropdown's
|
|
891
|
+
`triggerContent`, `header`, `footer` and `foot`; a nav or footer `footer` and `switcher`; a tab
|
|
892
|
+
item's `label` and `panel`; an empty state's SVG `art` and `actions`; a field's `control`; a
|
|
893
|
+
checkbox `label`; a snippet's code; a stat's `trend`; a brand `word`; a version switcher's label,
|
|
894
|
+
meta and custom badge; and `appShell()`'s `title`, `sub` and `body` plus the nested topbar slots.
|
|
895
|
+
A nested option inherits the contract of the factory it invokes.
|
|
896
|
+
|
|
897
|
+
## React components
|
|
898
|
+
|
|
899
|
+
The React wrapper publishes components over the same CSS. Its own notes are in
|
|
900
|
+
[react/README.md](../react/README.md). This section explains what React promises beyond the
|
|
901
|
+
vanilla sections above.
|
|
902
|
+
|
|
903
|
+
### React tables
|
|
904
|
+
|
|
905
|
+
Tables fill their container by default. Inside `.ui-card--fit`, tables size to their content.
|
|
906
|
+
A `.ui-table__title` cell gives a text column the remaining width. A column takes `cell` for it:
|
|
907
|
+
`title`, `code`, `long`, `strong` or `act`. `rowHeader` renders the column's body cells as `th scope="row"`.
|
|
908
|
+
`DataTable` takes the vanilla hooks as props: `zebra`, `hover` (on unless `false`), `density`,
|
|
909
|
+
`stickyHeader` and `pinnedIdentity`. `rowState` marks a row `target` or `dead`, `footer` takes totals rows
|
|
910
|
+
and `caption` names the table for assistive technology. A `dead` row is muted and shows its state as a word,
|
|
911
|
+
with no strike line. `stack` is deprecated and ignored: a phone table scrolls sideways like any other. A table that does not scroll is the card's own child, so a dense table reaches the card's text edge.
|
|
912
|
+
Its pager follows the measured table width and wraps when necessary.
|
|
913
|
+
Without `ResizeObserver`, the pager keeps its container width.
|
|
914
|
+
A pager that renders no controls takes no space.
|
|
915
|
+
|
|
916
|
+
Use `.ui-card--fit` when a card must end at its content.
|
|
917
|
+
The company comparison story aligns its heading, filters, tabs and first column through one shared inset.
|
|
918
|
+
Its empty result keeps the Clear filters action outside the scroll region.
|
|
919
|
+
Both filter bars accept `clearVariant="link"` with a custom `clearLabel`. Their existing defaults remain available.
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
Column labels accept React content, including a kit Tooltip that explains a header.
|
|
923
|
+
|
|
924
|
+
**A scrollable table reaches its far columns by scrolling, and offers no button for it.** Give it
|
|
925
|
+
`stickyHeader` or `pinnedIdentity`. The table then sits in a named scroll region. The region takes
|
|
926
|
+
keyboard focus and draws the kit's ring inward. A trackpad, a finger and the arrow keys can then
|
|
927
|
+
reach the same columns. `scrollLabel` provides the region's name. It defaults to `Table`, which
|
|
928
|
+
only says what the region contains. Pass the table's own subject instead, such as `Invoices`.
|
|
929
|
+
Name the gesture only when the columns overflow at every width the surface supports:
|
|
930
|
+
`Selectable companies, scroll for more columns`. A name has one state. If it names a gesture, that
|
|
931
|
+
gesture must be correct at every supported width.
|
|
932
|
+
|
|
933
|
+
**Sorting is yours to control or the table's to manage, and one table stays in one of those modes
|
|
934
|
+
for as long as it is on the page**. The default is the first sortable column, descending. An absent
|
|
935
|
+
sort key and equal values both preserve input order. Ordering returns its own list, so the rows you
|
|
936
|
+
supply are never reordered through the result. **Paging is on the same terms:** a controlled table
|
|
937
|
+
shows all the rows it was given. Those rows are the page, and you provide the count it reports.
|
|
938
|
+
`DataTable` builds its own class list and takes no `className`. It renders its sort control inside
|
|
939
|
+
the header cell. A stacked table clips that control. **A sortable header's label gives way with an
|
|
940
|
+
ellipsis rather than pushing the sort caret out of a capped column**, so a pinned sortable identity
|
|
941
|
+
keeps its direction visible on a phone.
|
|
942
|
+
|
|
943
|
+
**A column marked `linked` marks that column's body cells, and never its header**, which holds a
|
|
944
|
+
label or a sort control of its own. It is how a React table opts a column of ID or identity links
|
|
945
|
+
into the filled cell described under Dense financial tables.
|
|
946
|
+
|
|
947
|
+
### React auth shell
|
|
948
|
+
|
|
949
|
+
`AuthShell` centers one sign-in card and places the brand above its content. Pass the brand and the task content as React elements. The shell adds no background glow.
|
|
950
|
+
|
|
951
|
+
### React fields
|
|
952
|
+
|
|
953
|
+
`TextField`, `TextArea`, `SelectField` and `FileField` generate IDs for their controls and
|
|
954
|
+
messages. They also name their controls. **An error marks the control invalid and is described
|
|
955
|
+
before the hint rather than in its place**. This keeps a hint with consent, safety or legal detail
|
|
956
|
+
on screen while the reader decides whether to retry. The error also uses `role="alert"`, so a new
|
|
957
|
+
error is announced without moving focus. Required markers are decorative. Native controls carry
|
|
958
|
+
`required`. `Field` exposes the frame for a control that you render yourself. Its child function
|
|
959
|
+
receives a stable ID, `required`, `aria-invalid` and `aria-describedby`. Spread them on a `Dropdown` and the label and then the value name its trigger. `FileField` accepts one
|
|
960
|
+
file from the picker or by drop. `accept` only filters the system picker, so you validate before
|
|
961
|
+
upload.
|
|
962
|
+
|
|
963
|
+
### React toasts
|
|
964
|
+
|
|
965
|
+
React notices accept `compact`, `dismissible` and `timer`. `compact` omits body text.
|
|
966
|
+
`dismissible={false}` hides the close button without changing timing or action behavior.
|
|
967
|
+
`timer={false}` keeps the notice until the reader dismisses it. A numeric `timer` sets the
|
|
968
|
+
auto-dismiss seconds.
|
|
969
|
+
|
|
970
|
+
`Toast` and `useToast()` render the vanilla toast classes in a fixed stack. The newest notice is
|
|
971
|
+
at the bottom. The stack is anchored to the bottom-right corner. **The provider publishes how far
|
|
972
|
+
the stack reaches up the viewport** as `--rx-toast-stack` on the document root. It is `0px` while
|
|
973
|
+
the stack is empty. A fixed page action can use this value to stay clear of any number of notices.
|
|
974
|
+
Use **one** provider per document, because that property is a document-root global. Notices without
|
|
975
|
+
actions dismiss after five seconds. Their countdown and timer bar pause while hovered, focused or
|
|
976
|
+
held in a collapsed pile, then resume with the remaining time. Notices with an action stay until
|
|
977
|
+
the reader selects or dismisses it. Ordinary notices are polite. Danger notices are assertive.
|
|
978
|
+
Adding a notice does not move focus.
|
|
979
|
+
|
|
980
|
+
Pass `collapse` to `<Toast>` to draw the stack as a pile, as described under [Toast stacks](#toast-stacks).
|
|
981
|
+
The pile fans out on hover and on focus within it, and the stack stays a plain column on a device without hover.
|
|
982
|
+
|
|
983
|
+
## Toast stacks
|
|
984
|
+
|
|
985
|
+
A stack of notices can collapse into a pile. `.ui-toast-stack--collapsed` draws its notices on top
|
|
986
|
+
of one another, bottom-aligned, with the newest in front. Notices past `TOAST_TIERS` rest on the
|
|
987
|
+
last tier, so a ninth notice makes the pile no taller than a third one. The cards peeking behind
|
|
988
|
+
the front one are what say more is waiting. The pile carries no counted chip above it.
|
|
989
|
+
|
|
990
|
+
The pile fans out into the ordinary column on `:hover` and on `:focus-within`. Thus a keyboard
|
|
991
|
+
reader opens it by tabbing into it, and it collapses again when both states end. Nothing listens
|
|
992
|
+
for either state. The stylesheet switches between two sets of published values, which lets the
|
|
993
|
+
reduced-motion net cap the travel like any other transition.
|
|
994
|
+
|
|
995
|
+
The values are measured, because notices are not the same height. For each notice, a script
|
|
996
|
+
publishes `--toast-card-lift`, `--toast-card-scale`, `--toast-card-fan` and
|
|
997
|
+
`--toast-card-depth`. For the stack, it publishes `--toast-pile-height` and
|
|
998
|
+
`--toast-fan-height`. The React `Toast` measures and publishes them itself. A pile re-measures
|
|
999
|
+
when notices arrive or leave and when one changes height.
|
|
1000
|
+
|
|
1001
|
+
A notice behind the front one that is taller than the front one rests cut short, so no part of it
|
|
1002
|
+
shows below the front notice, even while the browser is busy. It opens to its own height when the
|
|
1003
|
+
pile fans out. The pile publishes `--toast-card-box` and `--toast-card-natural` for such a notice.
|
|
1004
|
+
|
|
1005
|
+
Under `(hover: none)` the stack stays the plain column. Half of what opens a pile is hover, and
|
|
1006
|
+
the notices behind the front card are not focusable. A pile there would be one nobody could open.
|
|
1007
|
+
|
|
1008
|
+
`.ui-toast__timer` spends the notice's own dismiss timer. It pauses on the notice's `:hover`,
|
|
1009
|
+
`:focus-within`, and on a held pile, so the line and the countdown stop together. Under reduced
|
|
1010
|
+
motion the line is not drawn at all, because its animation is capped to nothing. The countdown
|
|
1011
|
+
still pauses while the notice or the pile is held.
|
|
1012
|
+
|
|
1013
|
+
### React search field
|
|
1014
|
+
|
|
1015
|
+
`SearchField` is the unlabelled search box that a toolbar opens. It has a decorative leading glyph
|
|
1016
|
+
and a native `type="search"` control on the shared input class. **`ariaLabel` is required and is
|
|
1017
|
+
the control's only name**, because no label appears in the row. It declares no CSS of its own. The
|
|
1018
|
+
toolbar's row rule and the field's focus ring therefore reach it from the kit's stylesheet.
|
|
1019
|
+
**There is no clear button**, because the browser paints its own near-black button on the light
|
|
1020
|
+
field and white button on the dark one.
|
|
1021
|
+
|
|
1022
|
+
### React date and month picker
|
|
1023
|
+
|
|
1024
|
+
`DatePicker` picks one month, a range of months, one date or a range of dates. At its ordinary
|
|
1025
|
+
width, it uses the dropdown's shell and adds only the grid inside it. The panel is a `dialog`,
|
|
1026
|
+
because a calendar is a grid and a listbox may own only options. The panel is `inert` while closed.
|
|
1027
|
+
|
|
1028
|
+
**The grain and the span are two questions, not one:** `month` and `day` pick a single period.
|
|
1029
|
+
`range` and `day-range` pick a start and an end in the same two presses. Periods are ISO strings in
|
|
1030
|
+
the mode's own grain. Every step and comparison uses arithmetic on one integer per period. Nothing
|
|
1031
|
+
walks a `Date` across a daylight-saving boundary. **A period written in the other grain still
|
|
1032
|
+
counts**. A month read in day grain is its whole span. A date read in month grain is the month it
|
|
1033
|
+
falls in. A string that is neither is no bound. Bounds mark a cell `aria-disabled` and refuse the
|
|
1034
|
+
press, but **the cell stays focusable**, so a reader meets the bound instead of losing it.
|
|
1035
|
+
|
|
1036
|
+
**One tab stop in the grid, on the cell the keyboard is on**, and **Home and End go to the ends
|
|
1037
|
+
of the row without leaving the page**. **Every cell says what it is in its own accessible name.**
|
|
1038
|
+
**A range spans what lies between its ends — blocked periods included**, because
|
|
1039
|
+
`{ start, end }` cannot say "all of this but not that". Such a period keeps its place in the value
|
|
1040
|
+
and loses only the tint. **Blocked beats every other state in the paint, and its label is struck
|
|
1041
|
+
through.** **Hover is the kit's row hover**, not a tint of the accent. **The current period is a
|
|
1042
|
+
ring**, a hairline in the accent, and it stands aside while the cell holds focus, so a focused
|
|
1043
|
+
current period draws one band and not two. **Nothing is drawn under the grid:** no legend and no per-period
|
|
1044
|
+
swatch. **Below 560px the panel is a sheet, and a sheet is the kit's drawer**, and below the phone
|
|
1045
|
+
step the gap between weeks opens to reach the 44px tap floor. Its one breakpoint literal is one of
|
|
1046
|
+
the steps in [Breakpoints](foundations.md#breakpoints).
|
|
1047
|
+
|
|
1048
|
+
### React file drop
|
|
1049
|
+
|
|
1050
|
+
`FileDrop` is the compact drop: at rest, it shows one row with the button that opens the
|
|
1051
|
+
system picker. Beside the button, it shows the accepted types and size limit in your words.
|
|
1052
|
+
The field-sized dashed box remains with `FileField`. **You own the upload:** `FileDrop` sends
|
|
1053
|
+
a chosen or dropped file through `onFile` and renders the `file` you provide. **A file with no
|
|
1054
|
+
`status` is uploading**, so the kit never reports success unless you claim it. **A status the
|
|
1055
|
+
row draws includes a circled mark and a word**, because colour alone does not show status. When
|
|
1056
|
+
`progress` is provided, the track shows the status instead. `Remove` and `Retry` appear only
|
|
1057
|
+
when you provide `onRemove` and `onRetry`. **No tier ever takes a second line:** the name
|
|
1058
|
+
truncates its stem but keeps its extension. The full name is in a `title`. **One layout serves
|
|
1059
|
+
every width.** **The drop target is painted only while a file is over the region. It covers
|
|
1060
|
+
that region instead of joining it**, so the row stays in place while the reader aims. Children
|
|
1061
|
+
render above the row inside the same region. This lets one panel, or a whole page, become the
|
|
1062
|
+
target. A disabled drop never calls `preventDefault` on `dragover`, so it does not declare
|
|
1063
|
+
itself as a target the pointer can aim at. When a page uses a row, a region or a dialog, see
|
|
1064
|
+
[File drop](../guidelines/file-drop.md).
|
|
1065
|
+
|
|
1066
|
+
React `FileDrop` takes `title` to become the empty page's drop. It then draws a dashed box around
|
|
1067
|
+
a first-run block with the title, the accepted types and the Upload button. **The button is the
|
|
1068
|
+
keyboard path.** A click on the box opens the picker too. A file dropped anywhere in the box
|
|
1069
|
+
reaches `onFiles` with every file and `onFile` with the first; pass either or both, and add
|
|
1070
|
+
`multiple` to let the picker take several. A file over the box turns its edge to the accent. A
|
|
1071
|
+
disabled area accepts nothing.
|
|
1072
|
+
|
|
1073
|
+
`.ui-drop--page` is the kit's layer for a page that takes a file anywhere. Put it on the area's own
|
|
1074
|
+
markup, `.ui-drop.ui-drop--area.is-dragging`, and it becomes that area made large: a fixed box
|
|
1075
|
+
inset from the window and below the topbar, with the same dashed accent edge and radius, holding an
|
|
1076
|
+
`EmptyState` with the upload glyph, a line that says to drop the files and the accepted types.
|
|
1077
|
+
**Its ground is the page ground, slightly transparent and blurred, so the table shows through softly and no row stays sharp under the words.** Where the browser cannot blur what is behind, or the reader asks for less transparency, the ground is solid. The layer takes no pointer
|
|
1078
|
+
events, so the page keeps working under it. **Mount it only while a file is dragged over the page.** It has no fade and no rise, so reduced motion needs no
|
|
1079
|
+
second path. The page owns the drag logic, and its own Upload button stays the keyboard path.
|
|
1080
|
+
React ships no component for the layer.
|
|
1081
|
+
|
|
1082
|
+
### React Button links and leading artwork
|
|
1083
|
+
|
|
1084
|
+
React `Button` accepts `href` and then renders an anchor with the existing button classes.
|
|
1085
|
+
Without `href`, it renders a native button defaulting to `type="button"`. Refs and native
|
|
1086
|
+
attributes belong to whichever element it renders. `leading` accepts decorative content before
|
|
1087
|
+
the label wrapper and takes precedence over `icon`. For an icon-only control, the component
|
|
1088
|
+
copies string children, then the icon name, into `aria-label` and `title`. **With neither, it
|
|
1089
|
+
stays nameless instead of receiving an invented name.** `className` merges with the kit's
|
|
1090
|
+
classes. **The component's state wins over your spread props** — `aria-disabled`, `aria-busy`,
|
|
1091
|
+
the `data-btn-*` hooks, a link's `role`, and the `href` and `tabIndex` that a disabled or busy
|
|
1092
|
+
control removes. This prevents a caller from leaving a busy or disabled control looking idle.
|
|
1093
|
+
**Space is blocked on button roots only**, because it never activates an anchor. A busy link
|
|
1094
|
+
that swallowed Space would also prevent the reader from scrolling the page.
|
|
1095
|
+
|
|
1096
|
+
### React charts
|
|
1097
|
+
|
|
1098
|
+
`Chart` draws seven shapes: `months`, a column per period with bars and a line across them;
|
|
1099
|
+
`bridge`, one period walked from a starting total to a result; `spark`, one series at text
|
|
1100
|
+
size with no axis, for a stat band's `trend` slot; and `line`, `area`, `stacked` and `donut`. The numbers, the wording and the formatting
|
|
1101
|
+
are yours — `format` prints exact values in the readout, the live region and the table, and
|
|
1102
|
+
`formatAxis` prints the ticks, which are whole units.
|
|
1103
|
+
|
|
1104
|
+
**`line`, `area` and `stacked` take `periods` and `series`, and `donut` takes `slices`.** A series
|
|
1105
|
+
or a slice has no `shape`. Each of the four variants takes `look`, which picks one drawing of
|
|
1106
|
+
the same numbers:
|
|
1107
|
+
|
|
1108
|
+
| `variant` | `look` values | Default |
|
|
1109
|
+
| --- | --- | --- |
|
|
1110
|
+
| `line` | `thin`, `points` (a point on each value), `labels` (the last value at the line's end, and a chart that scrolls opens on its latest period) | `thin` |
|
|
1111
|
+
| `area` | `flat` (each series from zero), `curves` (each series from zero as a smooth curve, with a point on each value), `stacked`, `share` (each column is 100%) | `stacked` |
|
|
1112
|
+
| `stacked` | `columns`, `share` (each column is 100%), `rows` (a bar for each period) | `columns` |
|
|
1113
|
+
| `donut` | `thin` (the total in the centre), `table` (a list of the shares beside the ring), `labels` (the name, value and share at each slice) | `table` |
|
|
1114
|
+
|
|
1115
|
+
A series or a slice without a `tone` takes the next tone of `accent`, `accent-soft`, `info`,
|
|
1116
|
+
`warn`, `good`, `bad` and `neutral`. `area`, `stacked` and `donut` take only values of 0 or more, and a negative value throws a `RangeError` before anything is drawn. A stacked look reads a missing value as zero. The readout of
|
|
1117
|
+
a stacked or a share look lists each series of the column and the total, and the table adds a
|
|
1118
|
+
`Total` column. A share look gives the parts as percentages, and its table keeps your values.
|
|
1119
|
+
The arrow keys step through the periods, the rows or the slices. A donut slice says its value
|
|
1120
|
+
and its share of the whole. `totalLabel` names the whole, and it defaults to `Total`. A donut has
|
|
1121
|
+
no `selectable`.
|
|
1122
|
+
|
|
1123
|
+
**A mark is capped, whatever its column is worth.** A bar never passes a mark's width, so a chart
|
|
1124
|
+
that grows with the card gains ground between its columns rather than twelve wider blocks. Two bar
|
|
1125
|
+
series on the same side of the zero line stand side by side with ground between them; a
|
|
1126
|
+
`bars-below` series takes positive magnitudes and hangs under the line instead. A bar is
|
|
1127
|
+
rounded only at the end away from zero, and its foot stands square on the rule it is measured
|
|
1128
|
+
from. A bridge carries each step's running total across to the step beside it.
|
|
1129
|
+
|
|
1130
|
+
**A series takes one of seven fixed tones, and the product accent does not change them.** The
|
|
1131
|
+
tones are `accent`, `accent-soft`, `good`, `bad`, `warn`, `info` and `neutral`, with a light and a
|
|
1132
|
+
dark step for each theme. A bar fades from a light tint of its tone at its base on the zero line
|
|
1133
|
+
to the full tone at its data end, and a bar under zero fades the other way. The fill is opaque.
|
|
1134
|
+
The full tone clears 3:1 on the card and on the page in both themes. The tint is below 3:1 by
|
|
1135
|
+
design, because the data end, the zero line and the base carry the value. A bridge bar fades from
|
|
1136
|
+
the previous running total to the full tone at the new one, so a fall fades downwards. Lines,
|
|
1137
|
+
points and legend keys stay solid in the full tone. **An area ramps with its values:** the tint
|
|
1138
|
+
is at the series' lowest top and the full tone at its highest, in every column. An area with one
|
|
1139
|
+
value, a share band, a stacked part and a donut slice have no ramp. A `curves` area has a wash
|
|
1140
|
+
instead: its tone fades to clear at zero, under each series in the order you give them. Its curve
|
|
1141
|
+
never passes the values on each side of it and never goes under zero. Use `curves` for two or
|
|
1142
|
+
three series that the reader compares by shape, not by total.
|
|
1143
|
+
|
|
1144
|
+
**The legend shows only when you pass `legend`.** **An unfinished period keeps its series fill
|
|
1145
|
+
with a dashed edge.** The legend names the estimated state. The readout and the table show the
|
|
1146
|
+
state and its `note`.
|
|
1147
|
+
|
|
1148
|
+
**The value axis, the period row and the legend are quiet, and nothing is only there.** Every
|
|
1149
|
+
data value is reachable at full strength through pointer readouts and keyboard announcements.
|
|
1150
|
+
|
|
1151
|
+
**A switch in the top right corner shows the same numbers as a chart or as a table.** It is a
|
|
1152
|
+
toolbar of two glyph buttons named Chart and Table, with the pressed one marked. The chart shows
|
|
1153
|
+
first. The table replaces the plot, and the switch keeps its place. In a titled `<Card>` the
|
|
1154
|
+
switch sits at the end of the card's title row instead, and the chart draws no row of its own for
|
|
1155
|
+
it. When a card holds two charts, the first one puts its switch there. When that chart leaves,
|
|
1156
|
+
the next one takes the place. Pass `table={false}` to drop the switch and the table.
|
|
1157
|
+
|
|
1158
|
+
**Selection is a band behind the column, and focus is the ring on the chart.** Picking a column
|
|
1159
|
+
paints the column's own ground and sets its label in the strong ink at a heavier weight; no mark
|
|
1160
|
+
changes colour, so each tone stays with the series it names. The switch is the first tab stop
|
|
1161
|
+
and the chart is the second: Left,
|
|
1162
|
+
Right, Home and End step columns and announce each one politely, Enter picks one when `selectable`
|
|
1163
|
+
is set, and `title` names the plot, the table and the switch without being drawn, because the card
|
|
1164
|
+
around a chart already carries its title. A plot that scrolls adds one more tab stop after the
|
|
1165
|
+
chart: the scrolling box, named after `title` and ringed by the kit.
|
|
1166
|
+
|
|
1167
|
+
**On a touch screen a tap opens the readout and a second tap on the same mark closes it. The tap
|
|
1168
|
+
that opens a readout does not call `onSelect`** — it is the reader asking what a mark is worth.
|
|
1169
|
+
The tap that closes one, and an ordinary mouse click, do, and the click itself is never swallowed,
|
|
1170
|
+
so your own listener around the chart still hears every tap. Below 560px, to a coarse pointer, a
|
|
1171
|
+
line's point grows to the room its column gives. It never crosses into a neighbour's column. A
|
|
1172
|
+
narrow sparkline can therefore own less than 44px across, but it still owns at least 24px
|
|
1173
|
+
across and the full 44px down. A sparkline's slot grows with that vertical target, so a
|
|
1174
|
+
`trend` slot is 44px tall there instead of 32.
|
|
1175
|
+
|
|
1176
|
+
The table carries its columns sideways in a named scroller, so your card and your page keep their
|
|
1177
|
+
width whatever series you pass. At phone widths the plot scrolls with the value axis held in
|
|
1178
|
+
place, and a column cut by the edge shows that more periods are there. While the plot scrolls,
|
|
1179
|
+
the keyboard can scroll it from its own tab stop after the chart. Nothing animates.
|
|
1180
|
+
|
|
1181
|
+
### React route navigation
|
|
1182
|
+
|
|
1183
|
+
`NavTabs` uses the same presentation as the vanilla factory, so every
|
|
1184
|
+
guarantee above holds for it too. `NavTabs` takes unique item IDs, a controlled active ID, the
|
|
1185
|
+
underline or pill presentation, and optional badges. It uses native links and
|
|
1186
|
+
`aria-current="page"`, with no tablist or panel roles. **A disabled item is non-focusable text**
|
|
1187
|
+
marked `aria-disabled`, and cannot be the current link. An item with no destination uses its ID as
|
|
1188
|
+
a fragment. A badge of zero stays visible; a null or empty badge is dropped, the way the vanilla
|
|
1189
|
+
factory drops it.
|
|
1190
|
+
|
|
1191
|
+
It forwards root attributes and refs, keeps native link keyboard behaviour, and sends every
|
|
1192
|
+
destination through the kit's URL boundary.
|
|
1193
|
+
|
|
1194
|
+
**It takes `renderLink` with the signature `AppShell` uses**, so a router renders each link from
|
|
1195
|
+
the kit's class, destination, current state and children, and a route change need not reload the
|
|
1196
|
+
document.
|
|
1197
|
+
|
|
1198
|
+
`NavTabs` sizes its row on mount, on a route change and on window resize, preserving the reader's
|
|
1199
|
+
scroll position during content and container changes. It reveals the current route after mount and
|
|
1200
|
+
route changes, and reveals a link a focus event lands on. There is nothing to wire for it;
|
|
1201
|
+
`wireNav()` is for the vanilla rows. React imports the kit's own `safeUrl` and reveal functions
|
|
1202
|
+
rather than a copy bundled into `react/dist`.
|
|
1203
|
+
|
|
1204
|
+
### React top bar
|
|
1205
|
+
|
|
1206
|
+
`TopBar` composes `ViewSwitch`, `VersionSwitcher`, `ThemeToggle` and `AccountMenu` into the vanilla
|
|
1207
|
+
`topbar()` band, with the same classes and the same two rows on a phone. Each slot is optional, and
|
|
1208
|
+
no account is the signed-out bar. **The current view in the Deck and Text switch is filled with the
|
|
1209
|
+
accent fill of a chosen Segmented option**, in the vanilla switch as well as React's. **The version
|
|
1210
|
+
button shows only the chosen name**. **The open version menu shows each name and badge and ticks the chosen version**.
|
|
1211
|
+
The button and tick follow `value` until the caller updates it. `AccountMenu` marks the page named by `current` in accent ink.
|
|
1212
|
+
|
|
1213
|
+
### The rest of the React surface
|
|
1214
|
+
|
|
1215
|
+
- **`Tabs`** unmounts inactive panel content. Arrow keys, Home and End move between tabs and
|
|
1216
|
+
activate them.
|
|
1217
|
+
- **`Segmented`** is a controlled choice toolbar: one named toolbar, pressed buttons and **one
|
|
1218
|
+
Tab stop whatever the choice is.** Arrow keys wrap past disabled options; Home and End reach
|
|
1219
|
+
the first and last enabled choice. `block` fills the container with either appearance. An
|
|
1220
|
+
option's `icon` names a kit glyph drawn before its label. With `iconOnly`, the glyph is the
|
|
1221
|
+
whole button and the label becomes its accessible name.
|
|
1222
|
+
**`size="sm"` compacts the pill appearance only:** under the underline appearance it changes
|
|
1223
|
+
the type size and leaves the tab at its full height.
|
|
1224
|
+
- **`Confirm`** builds on `Modal` as an `alertdialog`. It focuses the safe action and draws it
|
|
1225
|
+
before the committing action. `onConfirm` only reports the press. Saving, errors and closing
|
|
1226
|
+
are yours.
|
|
1227
|
+
- **`Feedback`** offers a "Give feedback" pill on a text selection and opens a form with the
|
|
1228
|
+
quoted passage and a note. `onSend` files the note. A failed send keeps the note and shows the
|
|
1229
|
+
error in place. A sent note shows one line of thanks. Escape returns focus to the prior visible
|
|
1230
|
+
control, or to the pill if that control is unavailable.
|
|
1231
|
+
- **`Timeline`** renders your events from oldest to newest. **Only the last event's marker is
|
|
1232
|
+
filled.** A new ID in a non-empty history plays an entrance. Editing existing IDs does not.
|
|
1233
|
+
- **`AppShell`** shares the vanilla fold cookie and 720px fold. `layout="rail"` places the
|
|
1234
|
+
account at the rail foot and leaves only Sign out in its menu. It shows no section counts.
|
|
1235
|
+
Pass `back` to show the way up from a subpage, above the page title.
|
|
1236
|
+
**`tools` puts small tools for the whole page at the end of the title row** (#736), such as
|
|
1237
|
+
a version badge or a `size="sm"` button. The lede stands under the whole row. The tools do
|
|
1238
|
+
not wrap, so keep them to what fits beside a short title on a 390px phone. `actions` keeps
|
|
1239
|
+
the page's buttons in their own row under the title.
|
|
1240
|
+
**`accountItems` adds a product's rows, such as Account settings and Support, at the top of
|
|
1241
|
+
every account menu,** above the Theme row and Sign out. A row takes `href` to go somewhere,
|
|
1242
|
+
or `onSelect` to open something in place.
|
|
1243
|
+
The existing band layout stays the default. The longest matching section
|
|
1244
|
+
path wins. **At 720px and below, a menu button and the brand mark on the band replace the
|
|
1245
|
+
rail:** the button opens the full section list in the left drawer, and the page takes the full
|
|
1246
|
+
width. A press on a section, Escape or a wider window closes the drawer, and focus returns to
|
|
1247
|
+
the button. **A shell whose list has nowhere to go — one section and no back
|
|
1248
|
+
link — draws no rail, no fold control and no menu button;** the brand lockup moves to the band
|
|
1249
|
+
and the section stays in the command palette. One section under a child page is a destination,
|
|
1250
|
+
the page's parent, so that list is drawn and the row takes `aria-current="true"`.
|
|
1251
|
+
`searchLabel` names the band trigger's words. `searchShortLabel` is deprecated and not drawn.
|
|
1252
|
+
**`onNavigate` hands the built-in palette's same-tab picks to a client router,** so the page
|
|
1253
|
+
changes without a reload. An app's own `palette` wins: its `onNavigate` is used when it sets one.
|
|
1254
|
+
**With a sidebar, the account and `bandControl` stand in the sidebar, not on the band, and the
|
|
1255
|
+
theme is a row of the account menu** (#732). The rail keeps the fold's control
|
|
1256
|
+
in its head, `bandControl` under the head, then the sections and the account at its foot. A
|
|
1257
|
+
folded rail keeps the account mark, and makes `bandControl` inert. The drawer puts
|
|
1258
|
+
`bandControl` above the sections, and the account in its footer (`react/src/AppShell.tsx:229` `{accountBlock(true, true)}`).
|
|
1259
|
+
**`headControl` is one glyph control in the sidebar head, before the fold button** (#732). It
|
|
1260
|
+
is drawn as the fold is: a plain glyph with no border and no fill, the fold's size, ink and
|
|
1261
|
+
hover (`react/src/AppShell.css:56` `.ui-react-app__head-control > :is(button, a)`). A folded
|
|
1262
|
+
rail moves it out of the head row onto the glyph column, one rail gap under the head, and it
|
|
1263
|
+
stays usable. The drawer puts it in the panel's head, before the close button, as a 40px tap
|
|
1264
|
+
target (`react/src/AppShell.tsx:229` `headerActions={headSlot}`). `Drawer` takes
|
|
1265
|
+
`headerActions` for controls between its title and its close button. A shell with no sidebar
|
|
1266
|
+
puts `headControl` on the band after `bandControl`.
|
|
1267
|
+
**The Theme row opens a submenu of Auto, Light and Dark** (#736). The row shows the current
|
|
1268
|
+
choice, and a check marks it in the submenu. Right or Enter opens the submenu, Left or Escape
|
|
1269
|
+
closes it, and focus returns to the Theme row. A pick sets the theme and closes only the
|
|
1270
|
+
submenu. In the sidebar the submenu flies out beside the menu, past the sidebar's edge. In the
|
|
1271
|
+
drawer it replaces the menu's rows, under a Theme back row
|
|
1272
|
+
(`react/src/AccountMenu.tsx:18` `function AccountMenu`). A separator stands before Sign out. In the drawer a `.toggle` in
|
|
1273
|
+
`bandControl` and each account menu row are 40px tap targets, and focus starts on the first row.
|
|
1274
|
+
**Above 720px the band's search field stands in its centre** (`react/src/AppShell.css:93` `@media (min-width: 721px)`).
|
|
1275
|
+
**At 720px and below the band holds the mark, the page title on one line, search and Menu at
|
|
1276
|
+
the end, and nothing else.** The title ends in an ellipsis when it is long, and is hidden from
|
|
1277
|
+
screen readers, because the page's `h1` keeps its name (`react/src/AppShell.css:101` `.ui-react-app__title {`). **Below
|
|
1278
|
+
560px each band control is a bare 40px glyph with no border and no box**, so the band fits
|
|
1279
|
+
300px. The search trigger shows only its glyph there, an exception in
|
|
1280
|
+
`guidelines/iconography.md` (#729). The shared stylesheet clips the sentence and the key cap
|
|
1281
|
+
rather than dropping them, so the button keeps one accessible name at every width. A shell
|
|
1282
|
+
without a sidebar keeps `bandControl`, the theme switch and the account on its band.
|
|
1283
|
+
**When it mounts, the theme switch applies the stored theme choice, or follows the system when
|
|
1284
|
+
there is none.**
|
|
1285
|
+
A page that sets its own `data-theme` must also set `data-theme-choice`, or store the choice,
|
|
1286
|
+
to keep that theme. For example, `<html data-theme="light">` on a dark system turns dark
|
|
1287
|
+
when the shell mounts.
|
|
1288
|
+
- **`SidebarNav`** accepts flat items or captioned sections, nested groups, counts and
|
|
1289
|
+
router-link rendering. **Nesting stops one level deep.** Each row keeps its name and count when
|
|
1290
|
+
collapsed.
|
|
1291
|
+
- **`Checkbox` and `Switch`** render native inputs inside the existing label classes, and **a
|
|
1292
|
+
disabled one uses the same paint as every other disabled control in the kit.**
|
|
1293
|
+
- **A checkbox whose `indeterminate` property is true shows the checked fill with a short dash**
|
|
1294
|
+
in place of the tick. **`DataTable`'s selection boxes use the kit box and show the dash when some,
|
|
1295
|
+
but not all, rows on the page are selected.** **A selection column takes the width of its box in
|
|
1296
|
+
every selectable table, and in a dense or compact table the box's phone tap area stays 24px tall so
|
|
1297
|
+
it never reaches the next row.**
|
|
1298
|
+
- **`Checkbox` takes an optional `hint`,** which sits under the label words and is linked to the box as
|
|
1299
|
+
its description; the label stays the box's name. **`CheckList` groups `Checkbox` children in a
|
|
1300
|
+
fieldset under a legend** set in the field label's type. A disabled box dims its hint with its label.
|
|
1301
|
+
- **`Snippet`** displays `code` as plain text, and **copying always writes the original `code`
|
|
1302
|
+
string**, whatever `children` displays.
|
|
1303
|
+
- **`EmptyState`** uses the vanilla markup and CSS, and **the page supplies its own `h1`.**
|
|
1304
|
+
- **`ThemeToggle`** cycles through dark, light, auto, then dark. It stores explicit choices
|
|
1305
|
+
and follows the OS otherwise. It sets `data-theme-choice` and the resolved `data-theme` on
|
|
1306
|
+
`html` and exports `THEME_INIT_SCRIPT` for a head script.
|
|
1307
|
+
- **`Tooltip`** renders the vanilla host, panel and label classes. Escape keeps focus on the
|
|
1308
|
+
trigger.
|
|
1309
|
+
- **`Pill`** and **`StatusDot`** add no interactive role and create no live region. Visible
|
|
1310
|
+
status text belongs beside the dot.
|
|
1311
|
+
- **`SuccessPanel`** is the inline confirmation. **`SuccessCheck`** is the bare shared mark.
|
|
1312
|
+
- **Shared logic.** `dropdownMatch`, `dropdownFiltering`, `rankGroups`, `rankCommands`,
|
|
1313
|
+
`scoreCommand`, `paletteHotkey`, `segmentedNextIndex`, `PAGE_SIZES`, `DEFAULT_PAGE_SIZE`,
|
|
1314
|
+
`calloutIcons`, `chartScale`, `bridgeWalk`, `pointTarget` and `CHART_FLOOR` come from the main
|
|
1315
|
+
entry. So do `formatNumericValue` and
|
|
1316
|
+
`formatDeltaValue`. They return plain text and classes for React to render and never HTML.
|
|
1317
|
+
|
|
1318
|
+
## What the kit does not do
|
|
1319
|
+
|
|
1320
|
+
This is stated so nobody has to discover it by trying:
|
|
1321
|
+
|
|
1322
|
+
- **No build step**, whose consequence is
|
|
1323
|
+
[breakpoints as literals](foundations.md#breakpoints).
|
|
1324
|
+
- **No density system.** `.ui-table--dense`, `.ui-table--compact` and `.ui-cmdk--roomy` are the
|
|
1325
|
+
only density modifiers, and each is local to its component.
|
|
1326
|
+
- **No container scale.** There is one `--container`, not a narrow/wide set.
|
|
1327
|
+
- **No second bar for a control's glyph.** 1.5 CSS px is the line for every stroked mark.
|
|
1328
|
+
- **No charts.** A stat band's trend is a slot for your `<svg>`.
|
|
1329
|
+
- **No hand-written markup contract, except a row the kit renders as a control** — a `<div>` with
|
|
1330
|
+
a role and a tabindex, or an `<a>`, which you must rewrite as a `<button>` when it needs to
|
|
1331
|
+
work from the keyboard. Those class names are a supported surface.
|
|
1332
|
+
- **No support for a vertical writing mode.**
|
|
1333
|
+
|
|
1334
|
+
## Recipes
|
|
1335
|
+
|
|
1336
|
+
### A dropdown row you write yourself
|
|
1337
|
+
|
|
1338
|
+
`<button class="ui-dropdown__item">` renders the same row that `dropdown()` emits. Write
|
|
1339
|
+
one when the row must be a native control. The reason is explained in
|
|
1340
|
+
[A dropdown row is a div, a link or a button](#a-dropdown-row-is-a-div-a-link-or-a-button).
|
|
1341
|
+
|
|
1342
|
+
```html
|
|
1343
|
+
<button type="button" class="ui-dropdown__item" data-dd-item role="menuitem" tabindex="-1">
|
|
1344
|
+
<span class="ui-dropdown__main"><span class="ui-dropdown__label">Rename</span></span>
|
|
1345
|
+
</button>
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
`wireDropdown()` finds rows with `data-dd-item` inside `[data-dropdown-panel]`. It does not
|
|
1349
|
+
find them by class. These attributes make the row work:
|
|
1350
|
+
|
|
1351
|
+
- `data-dd-item` — without it, the row is not in the arrow-key ring or the click handler
|
|
1352
|
+
- `role="menuitem"` in a `menu` dropdown, `role="option"` in a `select` one
|
|
1353
|
+
- `tabindex="-1"` — the panel moves focus itself, while a `<button>` is in the tab order by default
|
|
1354
|
+
- `type="button"` — without it, a row inside a form submits the form
|
|
1355
|
+
- `aria-disabled="true"` for a disabled row, not the native `disabled` attribute: the item walk
|
|
1356
|
+
filters rows using this attribute
|
|
1357
|
+
- `aria-selected="true|false"` on a `select` row, and keep the `.ui-dropdown__label` span — the
|
|
1358
|
+
pick is written to `aria-selected` on the row itself, never on a span inside it, and the row
|
|
1359
|
+
also takes `is-selected`, which is what shows its tick. The trigger's `.ui-dropdown__value`
|
|
1360
|
+
text is copied from the picked row's `.ui-dropdown__label`
|
|
1361
|
+
- `data-value="…"` if you read the pick from the element
|
|
1362
|
+
|
|
1363
|
+
### Forms
|
|
1364
|
+
|
|
1365
|
+
`field()` provides wiring that a control cannot provide for itself. It sets the label's `for=`,
|
|
1366
|
+
adds an id to the hint or error and points to it with `aria-describedby`, adds `aria-invalid`
|
|
1367
|
+
to a field with an `error`, and adds the native `required` attribute under the decorative
|
|
1368
|
+
asterisk. **A `dropdown()` inside `field()` is wired through its trigger button**, because the
|
|
1369
|
+
dropdown's `id` sits on a wrapper that a label cannot name. The label and then the chosen value name
|
|
1370
|
+
the trigger, the error or hint describes it, and an error marks it invalid. The list is named by the
|
|
1371
|
+
label unless you give it an `ariaLabel`. A control outside a `field()` needs its own `ariaLabel`. A
|
|
1372
|
+
placeholder is not a name. Put a form on a card, not on the page ground. A field is drawn by its edge, but the page ground
|
|
1373
|
+
is too close to the field's own fill for you to see that edge. See
|
|
1374
|
+
[Colour and contrast](foundations.md#colour-and-contrast).
|
|
1375
|
+
|
|
1376
|
+
### Segmented or tabs?
|
|
1377
|
+
|
|
1378
|
+
Ask what is behind the choice. If choosing an option reveals a different block of content, that
|
|
1379
|
+
content is a panel. Use `tabs()`. It renders the panels and lets a screen reader announce
|
|
1380
|
+
"tab, 1 of 3" truthfully. If choosing an option only narrows a list, flips a unit or sets a
|
|
1381
|
+
preference, there is no panel. Use `segmented()`. It says "pressed" instead of "selected".
|
|
1382
|
+
Both give a keyboard user one Tab stop. Both need a name, so pass `ariaLabel`.
|
|
1383
|
+
|
|
1384
|
+
### successPanel or success?
|
|
1385
|
+
|
|
1386
|
+
Ask how much of the screen the confirmation owns. After a form has been submitted, or inside a
|
|
1387
|
+
card on a page where the reader stays, use `successPanel({ title, sub })`. When the confirmation
|
|
1388
|
+
*is* the screen and the reader needs somewhere to go next, use `success()`. It chooses a layout,
|
|
1389
|
+
carries follow-up buttons and can run a redirect countdown after you call `wireSuccess()` on the
|
|
1390
|
+
mounted element. Restyling one does not move the other: `successPanel` is `.ui-success` and
|
|
1391
|
+
`success` is `.ui-sx`. Both draw `successCheck()`.
|
|
1392
|
+
|
|
1393
|
+
---
|
|
1394
|
+
|
|
1395
|
+
Install, usage and the publish flow are in the [top-level README](../README.md).
|