actual-css 0.16.0 → 0.17.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +8 -4
  3. package/components.json +21 -5
  4. package/dist/actual.full.css +410 -75
  5. package/dist/actual.full.js +2 -1
  6. package/dist/actual.full.min.css +1 -1
  7. package/docs/design-notes/app-ui.md +37 -3
  8. package/docs/design-notes/enhancement-contract.md +3 -1
  9. package/docs/design-notes/tokens.md +2 -0
  10. package/docs/navigation.json +14 -1
  11. package/docs/pages/components/accordion.md +5 -0
  12. package/docs/pages/components/alert.md +45 -17
  13. package/docs/pages/components/button.md +3 -0
  14. package/docs/pages/components/chat.md +20 -0
  15. package/docs/pages/components/dialog.md +36 -0
  16. package/docs/pages/components/drawer.md +52 -8
  17. package/docs/pages/components/navbar.md +26 -2
  18. package/docs/pages/components/rating.md +111 -12
  19. package/docs/pages/components/segmented.md +36 -1
  20. package/docs/pages/components/spinner.md +2 -0
  21. package/docs/pages/components/table.md +77 -0
  22. package/docs/pages/components/timeline.md +3 -1
  23. package/docs/pages/enhancements/flyout.md +83 -14
  24. package/docs/pages/enhancements/status-bar.md +1 -0
  25. package/docs/pages/enhancements/tabs.md +5 -0
  26. package/docs/pages/examples/overview.md +7 -1
  27. package/docs/pages/forms/ajax.md +101 -0
  28. package/docs/pages/forms/color-swatches.md +31 -2
  29. package/docs/pages/forms/date-picker.md +6 -0
  30. package/docs/pages/forms/joined-controls.md +8 -3
  31. package/docs/pages/forms/overview.md +2 -2
  32. package/docs/pages/forms/sticky-actions.md +2 -0
  33. package/docs/pages/forms/unsaved-changes.md +198 -0
  34. package/docs/pages/foundations/philosophy.md +2 -1
  35. package/docs/pages/foundations/theming.md +21 -4
  36. package/docs/pages/foundations/tokens.md +1 -1
  37. package/docs/pages/guides/introduction.md +1 -1
  38. package/docs/pages/guides/progressive-enhancement.md +30 -49
  39. package/docs/pages/guides/upgrading.md +16 -3
  40. package/docs/pages/layout/choosing.md +5 -0
  41. package/docs/pages/layout/column-layout.md +22 -8
  42. package/docs/pages/layout/scroll-snap.md +69 -2
  43. package/docs/pages/layout/sidebar-shell.md +68 -0
  44. package/docs/pages/patterns/empty-state.md +74 -0
  45. package/docs/pages/patterns/hierarchical-nav.md +40 -19
  46. package/docs/pages/patterns/navigation-list.md +3 -60
  47. package/docs/pages/patterns/stat.md +61 -0
  48. package/docs/pages/utilities/accessibility.md +32 -10
  49. package/package.json +4 -1
  50. package/reserved-classes.json +2 -0
  51. package/src/css/components/busy.css +25 -0
  52. package/src/css/components/button.css +3 -0
  53. package/src/css/components/chat.css +5 -1
  54. package/src/css/components/drawer.css +37 -3
  55. package/src/css/components/flyout.css +37 -0
  56. package/src/css/components/modal.css +3 -0
  57. package/src/css/components/navbar.css +99 -38
  58. package/src/css/components/rating.css +50 -5
  59. package/src/css/components/segmented.css +25 -2
  60. package/src/css/components/status-bar.css +4 -2
  61. package/src/css/forms/choice-card.css +5 -2
  62. package/src/css/forms/color-swatch.css +38 -19
  63. package/src/css/forms/custom-select.css +5 -0
  64. package/src/css/forms/form.css +3 -1
  65. package/src/css/layout/index.css +2 -0
  66. package/src/css/layout/sidebar-shell.css +67 -0
  67. package/src/js/ajax.js +148 -0
  68. package/src/js/dialog.js +59 -2
  69. package/src/js/dirty.js +140 -0
  70. package/src/js/dismiss.js +25 -0
  71. package/src/js/events.js +17 -0
  72. package/src/js/focus.js +12 -0
  73. package/src/js/form-submission.js +34 -0
  74. package/src/js/full.js +2 -0
  75. package/src/js/selectors.js +10 -2
  76. package/src/js/status.js +71 -10
  77. package/src/js/tab.js +16 -2
  78. package/src/js/validation.js +12 -4
  79. package/src/tooling/theme-contrast.js +3 -2
@@ -4,9 +4,10 @@ Actual CSS provides application chrome and content composition without owning
4
4
  the application lifecycle.
5
5
 
6
6
  ```text
7
- app-shell full-height single-column document flow
8
- topbar persistent top application chrome
9
- app-layout specialized topbar + internal scroll + adaptive navigation recipe
7
+ app-shell full-height single-column document flow
8
+ sidebar-shell persistent side region + main, each scrolling, on a wide viewport
9
+ topbar persistent top application chrome
10
+ app-layout specialized topbar + internal scroll + adaptive navigation recipe
10
11
  app-nav primary application destinations
11
12
  list repeated application rows with leading/content/trailing regions
12
13
  status-bar passive transient feedback
@@ -22,6 +23,39 @@ application. Actual does not prescribe Material breakpoints or device classes;
22
23
  the application layout changes when its available viewport can accommodate
23
24
  labelled side navigation.
24
25
 
26
+ ## Sidebar shell
27
+
28
+ An admin or dashboard keeps a sidebar beside its content on a wide screen and
29
+ hands it to a drawer on a phone. None of the existing shapes is that:
30
+ `.app-shell` is one column, `.sidebar-layout` a wrapping pair inside a page,
31
+ and `.app-layout` moves navigation to a bottom bar.
32
+
33
+ Contract:
34
+
35
+ - Two direct children: an `aside` (the side region, any content) and one
36
+ other element (the main region). The drawer is a separate `dialog.drawer`
37
+ outside the shell; the two are never one element transformed.
38
+ - At `64rem` and up, a viewport-height grid, side then main. Each region
39
+ scrolls on its own, so the sidebar never scrolls away with the content.
40
+ - Below `64rem`, the side region is hidden and the document scrolls. A phone
41
+ keeps its native behaviors: the collapsing URL bar, tap-to-top, and a
42
+ virtual keyboard that resizes the document rather than a fixed box.
43
+ - The breakpoint is a literal: a custom property cannot sit in a media
44
+ condition. A project that needs another one copies the two rules.
45
+ - Hidden with `(width < 64rem)`, not shown above it: the side region keeps
46
+ the author's own `display` (an `aside.stack`). Where range syntax is
47
+ unsupported the rule drops and the sidebar stacks above the content, still
48
+ reachable.
49
+ - CSS only. Closing an open drawer when the viewport widens belongs to the
50
+ page (`matchMedia` change → `dialog.close()`), a documented recipe rather
51
+ than a watcher in the primitive.
52
+ - Print is one flow, side then main, nothing clipped. The narrow rule is
53
+ `screen` only: print never hides framework content, so leaving the sidebar
54
+ off paper is the application's print stylesheet.
55
+
56
+ Rejected: a bottom navigation (that is `.app-layout`), a collapsible icon rail
57
+ (an application state), and a breakpoint hook (impossible in a media query).
58
+
25
59
  Compact UI vocabulary remains semantic rather than shape-driven:
26
60
 
27
61
  - use `.btn.sm` for compact actions and `aria-pressed` filters;
@@ -178,5 +178,7 @@ of the contract itself.
178
178
  | `range` | Fill share and named-value synchronization | `.range` |
179
179
  | `scrollspy` | Scroll-driven nav highlighting | `.scrollspy` |
180
180
  | `validation` | Form validation, focus management, server errors | `.needs-validation` |
181
+ | `dirty` | Unsaved-changes state on a form | — |
182
+ | `ajax` | Form submission through `fetch` | — |
181
183
 
182
- Five tokens. Everything else stays self-describing.
184
+ Seven tokens. Everything else stays self-describing.
@@ -47,6 +47,8 @@ Neutral roles may lean toward the palette's ambient hue — by default the prima
47
47
 
48
48
  Semantic intents are curated colors, not mechanical derivatives of `--primary`. Danger, warning, and success stay recognizable for their function, but they are chosen as members of the theme palette rather than copied independently from a generic scale. Neither intents nor neutrals are derived from `--primary` at runtime: the relationship is a design decision recorded in the theme's own values.
49
49
 
50
+ Actual ships a theme, not a palette. A palette lists available colors (`blue-100` … `blue-900`); a theme assigns meaning (primary, danger, surface, text). Components consume only the roles, so bundled color scales would add hundreds of custom properties the framework never reads and widen the public API without adding behavior. Applications bring their own source — a palette library, brand guidelines, literal values — and map it to the roles at the theme boundary.
51
+
50
52
  Color should reinforce structure and meaning, not carry them alone. Information hierarchy and semantic states should remain understandable when hue is removed or unavailable. Desaturating a composition is a useful review heuristic, not a conformance test.
51
53
 
52
54
  ## Soft foreground calibration
@@ -1,4 +1,12 @@
1
1
  {
2
+ "destinations": [
3
+ { "title": "Get started", "icon": "rocket", "groups": ["guides", "foundations", "examples"] },
4
+ { "title": "Layout", "icon": "layout-grid", "groups": ["layout"] },
5
+ { "title": "Components", "icon": "components", "groups": ["components", "patterns"] },
6
+ { "title": "Forms", "icon": "forms", "groups": ["forms"] },
7
+ { "title": "Utilities", "icon": "tool", "groups": ["utilities"] },
8
+ { "title": "Enhancements", "icon": "bolt", "groups": ["enhancements"] }
9
+ ],
2
10
  "groups": [
3
11
  {
4
12
  "title": "Guides",
@@ -38,6 +46,7 @@
38
46
  "scroll-target",
39
47
  "frame",
40
48
  "app-shell",
49
+ "sidebar-shell",
41
50
  "app-layout"
42
51
  ]
43
52
  },
@@ -102,6 +111,8 @@
102
111
  "password",
103
112
  "input-policy",
104
113
  "validation",
114
+ "unsaved-changes",
115
+ "ajax",
105
116
  "detached-actions",
106
117
  "sticky-actions"
107
118
  ]
@@ -118,7 +129,9 @@
118
129
  "hierarchical-nav",
119
130
  "code-block",
120
131
  "exclusive-accordion",
121
- "intent-nesting"
132
+ "intent-nesting",
133
+ "empty-state",
134
+ "stat"
122
135
  ]
123
136
  },
124
137
  {
@@ -168,3 +168,8 @@ recipe repeats it on its own property:
168
168
  }
169
169
  }
170
170
  ```
171
+
172
+ The [playful FAQ template](../../demo/templates/playful-faq.html) applies this
173
+ recipe with a local palette and animates the panel opening and closing (smooth
174
+ expand / collapse, height animation) through `::details-content`, without
175
+ JavaScript.
@@ -2,6 +2,8 @@
2
2
 
3
3
  > Inline status messages for confirmations, warnings, and errors, with intents, icons, and action lists.
4
4
 
5
+ **Related terms:** banner, callout, notice, inline notification, install prompt, trailing action.
6
+
5
7
  - Supports intent colors.
6
8
  - Supports longer text and lists.
7
9
  - Links inherit alert color by default.
@@ -35,6 +37,23 @@ itself needs to change, not `.soft`.
35
37
  | Shared variants | Variant | `.solid`, `.outline`, `.surface`. |
36
38
  | Density contexts | Density | Descendant rhythm; inline padding stays stable. |
37
39
 
40
+ ## Anatomy
41
+
42
+ ```text
43
+ .alert
44
+ ├── .alert-icon (optional)
45
+ ├── content any HTML, one or more blocks
46
+ └── .close (optional)
47
+
48
+ .alert.admonition
49
+ ├── .alert-title
50
+ │ ├── icon (optional)
51
+ │ ├── title text
52
+ │ └── .close (optional)
53
+ └── .alert-body
54
+ └── content any HTML
55
+ ```
56
+
38
57
  ## Basic usage
39
58
 
40
59
  `.surface` comes first on purpose: it keeps the theme's own chrome and puts the
@@ -64,16 +83,12 @@ intent treatment when the color itself carries the meaning.
64
83
  </div>
65
84
 
66
85
  <div class="alert danger" role="alert">
67
- <strong>Error!</strong>
68
- <div>Something went wrong.</div>
69
- </div>
70
-
71
- <div class="alert danger" role="alert">
72
- I'm a simple error
86
+ <strong>Couldn't save the draft.</strong>
87
+ <div>The connection dropped. Your changes are kept on this device.</div>
73
88
  </div>
74
89
 
75
90
  <div class="alert danger" role="alert">
76
- I'm a simple error <a href="#">with a link and no joke</a>
91
+ Your session expired. <a href="#">Sign in again</a>.
77
92
  </div>
78
93
  </div>
79
94
  ```
@@ -103,19 +118,32 @@ intent treatment when the color itself carries the meaning.
103
118
  The grid pins `.alert-icon` and `.close` to the outer columns. A
104
119
  trailing link or button is content, not anatomy, so it lives in the text column:
105
120
  wrap the row in a `.cluster` and push the two ends apart. Same recipe as any
106
- split / spread row — there is no `.alert-action` class.
121
+ split / spread row — there is no `.alert-action` class. The action sits before
122
+ `.close` on a wide alert and wraps under the message on a narrow one.
107
123
 
108
124
  The alert aligns its columns to the block start, so a multi-line message keeps
109
- its icon on the first line. A trailing control makes that row taller than a line
110
- of text: add `.items-center` to put the icon, the text and the button on one
111
- center.
125
+ its icon and `.close` on the first line. A trailing control makes a one-line
126
+ row taller than its text: add `.items-center` to put the icon, the text and the
127
+ button on one center. Leave it off when the message can wrap — the icon would
128
+ center on the whole block.
112
129
 
113
130
  ```html demo
114
- <div class="alert surface items-center">
115
- <i class="ti ti-info-circle alert-icon" aria-hidden="true"></i>
116
- <div class="cluster justify-content-space-between">
117
- <strong>New message!</strong>
118
- <a class="btn sm outline" href="#">Open</a>
131
+ <div class="stack">
132
+ <div class="alert surface items-center">
133
+ <i class="ti ti-info-circle alert-icon" aria-hidden="true"></i>
134
+ <div class="cluster justify-content-space-between">
135
+ <strong>New message!</strong>
136
+ <a class="btn sm outline" href="#">Open</a>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="alert primary" id="install-alert">
141
+ <i class="ti ti-download alert-icon" aria-hidden="true"></i>
142
+ <div class="cluster justify-content-space-between">
143
+ <p><strong>Recommended</strong> · Install the desktop app for notifications and offline access.</p>
144
+ <a class="btn sm" href="#">Install app</a>
145
+ </div>
146
+ <button class="close" type="button" commandfor="install-alert" command="--dismiss" aria-label="Dismiss"></button>
119
147
  </div>
120
148
  </div>
121
149
  ```
@@ -140,7 +168,7 @@ center.
140
168
 
141
169
  ## Dismiss
142
170
 
143
- Add a `.close` button to let a user remove an inline alert. Inside an alert it is compact and at reduced opacity, and it follows the alert's ink with any intent. The runtime `--dismiss` command removes the alert — no custom script.
171
+ Add a `.close` button to let a user remove an inline alert. Inside an alert it is compact and at reduced opacity, and it follows the alert's ink with any intent. Give the alert an `id` and point the button at it with `commandfor` and `command="--dismiss"`: the runtime hides the alert (`hidden`) and moves focus to the next control — no custom script. See [Dismiss command](../guides/progressive-enhancement.md#dismiss-command).
144
172
 
145
173
  ```html demo
146
174
  <div class="alert warning" id="warning-alert">
@@ -149,6 +149,9 @@ and collapses the shared edges.
149
149
  </div>
150
150
  ```
151
151
 
152
+ Name a button group with `role="group"` and a label; an input with one
153
+ attached button takes neither (see [joined controls](../forms/joined-controls.md)).
154
+
152
155
  Use the same variant across a group. Change a button's variant to mark a
153
156
  meaningful state, such as a solid pressed [toggle](#toggle) among outlines.
154
157
  For one choice among a few on a shared track, use a
@@ -30,6 +30,24 @@ also follows right-to-left writing direction. The avatar is optional. Bubble
30
30
  colors compose with intents and shared variants: `.primary`, `.primary.soft`,
31
31
  and `.primary.outline` all work without chat-specific color classes.
32
32
 
33
+ The avatar sits beside the last line by default, as in messaging. For a long
34
+ message with a footer — an assistant answer, a comment with its actions — set
35
+ `--chat-avatar-align: start` to keep it beside the header.
36
+
37
+ ```html demo
38
+ <div class="chat chat-start" style="--chat-avatar-align: start">
39
+ <div class="chat-avatar avatar sm" role="img" aria-label="Assistant">
40
+ <span aria-hidden="true">A</span>
41
+ </div>
42
+ <div class="chat-header">Assistant <time datetime="2026-08-18T21:31">21:31</time></div>
43
+ <div class="chat-bubble">
44
+ Three invoices are overdue. The largest, INV-2041, is 47 days late; I drafted a
45
+ reminder for it and left the other two for review.
46
+ </div>
47
+ <div class="chat-footer">Sources: Invoices, Customer contacts</div>
48
+ </div>
49
+ ```
50
+
33
51
  For a live conversation, put an appropriate live-region or `role="log"` on the
34
52
  conversation container according to the product's announcement needs. Do not
35
53
  put `role="log"` on individual messages.
@@ -53,3 +71,5 @@ Formatting needs a hosted editor instead — see the
53
71
 
54
72
  - `--chat-gap` — gap between the avatar and message content.
55
73
  - `--chat-max-size` — maximum inline size of a bubble.
74
+ - `--chat-avatar-align` — the avatar's block alignment: `end` (default) beside
75
+ the last line, `start` beside the header for long messages with a footer.
@@ -519,6 +519,8 @@ Available options:
519
519
  * `data-dialog-modal="false"` makes direct `openDialog()` calls use `show()`
520
520
  instead of `showModal()`. The `show-modal` and `--show` commands override
521
521
  this default.
522
+ * `data-dialog-open` opens the dialog once after parsing, using its
523
+ `data-dialog-modal` mode. See [Open on load](#open-on-load).
522
524
  * `data-dialog-view-transition` enables a view transition that morphs the dialog to/from its trigger. Only active when the browser supports `document.startViewTransition` and the user allows motion.
523
525
  * `closedby` keeps its native meaning: `"any"` closes on backdrop click and
524
526
  Escape, `"closerequest"` closes on Escape only, `"none"` disables both. The
@@ -527,6 +529,40 @@ Available options:
527
529
  `closedby="none"`. Use `closedby="none"` for critical dialogs that must be
528
530
  closed by an explicit action.
529
531
 
532
+ ### Open on load
533
+
534
+ Add `data-dialog-open` to show a dialog without a trigger, for example a
535
+ confirmation rendered by the server after a form submission. Load
536
+ `actual-css/js/dialog` or the full runtime; no application script is needed.
537
+
538
+ ```html
539
+ <dialog class="modal" id="confirmation" open data-dialog-open>
540
+ <form method="dialog" class="stack">
541
+ <h2>Check your inbox</h2>
542
+ <p>We sent you a link to confirm your email address.</p>
543
+ <footer class="cluster justify-content-end">
544
+ <button class="btn primary" value="done">Got it</button>
545
+ </footer>
546
+ </form>
547
+ </dialog>
548
+ ```
549
+
550
+ The native `open` attribute keeps the confirmation visible, non-modally,
551
+ without JavaScript. The runtime upgrades it to a modal after parsing. Omit
552
+ `open` to keep it hidden without JavaScript, or add `data-dialog-modal="false"`
553
+ to keep the automatic opening non-modal. `data-dialog-open="false"` disables
554
+ automatic opening; it does not hide a dialog that already has `open`.
555
+
556
+ Automatic opening runs once per element: moving or reinserting a dismissed
557
+ dialog does not reopen it, while a fresh node inserted by an Ajax response
558
+ opens on connection. A dialog already opened modally by a command stays open.
559
+ Automatic opening skips the trigger view transition and leaves focus
560
+ restoration on close to the browser.
561
+
562
+ The [Settings modal demo](../../demo/templates/settings-modal.html) uses
563
+ `open data-dialog-open` to show its preferences on load. Close the dialog to
564
+ reach its Open settings button and reopen it with a command.
565
+
530
566
  ## Browser support
531
567
 
532
568
  Actual relies on the native `<dialog>` API in its supported JavaScript range
@@ -1,15 +1,15 @@
1
1
  # Drawer
2
2
 
3
- > Modal side-sheet that overlays the page for navigation or filters.
3
+ > Modal side or bottom sheet that overlays the page for navigation, filters or actions.
4
4
 
5
- **Related terms:** off-canvas, side panel, side sheet, navigation drawer.
5
+ **Related terms:** off-canvas, side panel, side sheet, navigation drawer, bottom sheet, action sheet.
6
6
 
7
7
  ## Class reference
8
8
 
9
- | Class | Kind | Description |
10
- | --------- | ----------- | -------------------------------------------------------- |
11
- | `.drawer` | Component | Modal side-sheet built on the native `<dialog>` element. |
12
- | `.close` | Composition | Icon-only close button, at the top end. |
9
+ | Class | Kind | Description |
10
+ | --------- | ----------- | ---------------------------------------------------- |
11
+ | `.drawer` | Component | Modal side or bottom sheet on the native `<dialog>`. |
12
+ | `.close` | Composition | Icon-only close button, at the top end. |
13
13
 
14
14
  ## Usage
15
15
 
@@ -20,7 +20,8 @@
20
20
  only gates backdrop click: Escape and the close button always close.
21
21
  - Use `closedby="none"` when the drawer must not be dismissed by the user at all
22
22
  (e.g. a form with unsaved changes): no backdrop close and no Escape close.
23
- - Use `[data-side="end"]` for a right-side drawer.
23
+ - Use `[data-side="end"]` for a right-side drawer, `[data-side="bottom"]` for
24
+ a [bottom sheet](#bottom-sheet).
24
25
  - Put the body between a `header` and a `footer`: the panel is a three-row grid
25
26
  whose middle region scrolls, so the footer stays reachable however long the
26
27
  content gets.
@@ -119,9 +120,52 @@ so the two never double-handle. Without `data-dialog-dismissible`, a native
119
120
  light dismiss briefly flash instead of closing when the backdrop is clicked —
120
121
  useful for drawers that should not be dismissed accidentally.
121
122
 
123
+ ## Bottom sheet
124
+
125
+ `data-side="bottom"` puts the drawer on the bottom edge: full width, as tall as
126
+ its content up to `--drawer-size` or 85% of the viewport, with rounded top
127
+ corners. The header, scrolling body and footer work as on a side drawer, and
128
+ the bottom padding clears the iOS home indicator. Use it for filters, pickers
129
+ and contextual actions on a phone.
130
+
131
+ ```html demo
132
+ <button class="btn"
133
+ type="button"
134
+ command="show-modal"
135
+ commandfor="sort-sheet"
136
+ aria-haspopup="dialog"
137
+ aria-controls="sort-sheet">
138
+ Sort
139
+ </button>
140
+
141
+ <dialog class="drawer" id="sort-sheet" data-side="bottom" aria-labelledby="sort-sheet-title" closedby="any">
142
+ <form method="dialog">
143
+ <header>
144
+ <strong id="sort-sheet-title">Sort by</strong>
145
+ <button class="close" type="submit" aria-label="Close"></button>
146
+ </header>
147
+
148
+ <fieldset class="field-group flush stack">
149
+ <legend class="sr-only">Sort by</legend>
150
+ <label class="choice"><input class="radio" type="radio" name="sort" value="relevance" checked><span>Relevance</span></label>
151
+ <label class="choice"><input class="radio" type="radio" name="sort" value="date"><span>Soonest date</span></label>
152
+ <label class="choice"><input class="radio" type="radio" name="sort" value="price"><span>Lowest price</span></label>
153
+ </fieldset>
154
+
155
+ <footer class="cluster justify-content-end">
156
+ <button class="btn primary" value="apply">Apply</button>
157
+ </footer>
158
+ </form>
159
+ </dialog>
160
+ ```
161
+
162
+ No drag handle and no swipe to close: those are gestures, not layout. When the
163
+ same task is a flyout on a desktop and a sheet on a phone, the page picks the
164
+ surface; see [Adaptive filter surface](../../demo/templates/adaptive-surface.html).
165
+
122
166
  ## CSS hooks
123
167
 
124
- - `--drawer-size` — panel width.
168
+ - `--drawer-size` — panel width; the maximum height of a bottom sheet.
125
169
  - `--drawer-pad` — panel padding.
126
170
  - `--close-size` / `--close-icon-size` — size of the corner [`.close`](close.md)
127
171
  and of its X. The header reserves the close size plus `--space-30` on its
@@ -7,8 +7,12 @@
7
7
  - Horizontal links live in a `.cluster`; its items are `.nav-link`.
8
8
  - `.nav-list` is the shared vertical navigation list, reused by `.drawer` for stacked links.
9
9
  - Mark the current page with `aria-current="page"` on the active `.nav-link`,
10
- or the current section of the page with `aria-current="location"` (what
11
- scrollspy sets). Any other value is inert.
10
+ the current section of the page with `aria-current="location"` (what
11
+ scrollspy sets), or a section link whose section holds the current page with
12
+ `aria-current="true"` (a top bar of site sections). Any other value is inert.
13
+ Mark one current item per navigation; a header and a sidebar are two
14
+ navigations, so each has its own — "Components" (`true`) in the header and
15
+ "Rating" (`page`) in the sidebar.
12
16
 
13
17
  For a public or normally scrolling page, `.navbar` belongs inside the semantic
14
18
  site header. Do not use `.topbar` or `.app-layout` unless the page actually has
@@ -53,6 +57,26 @@ full-row hit target for vertical navigation. The [Workspaces example](../example
53
57
  shows the sectioned-sidebar composition: grouped `.nav-list` blocks with
54
58
  section titles, a pinned account footer, and the native current state.
55
59
 
60
+ ## Current link
61
+
62
+ The current link (active page, selected item, highlighted menu entry) takes
63
+ full text ink on a neutral fill, one step stronger than hover, in a bar and in
64
+ a `.nav-list` alike. Forced colors adds a shape: an underline on horizontal
65
+ links, an inline-start trait in `.nav-list`.
66
+
67
+ Restyle it with `--nav-current-bg` and `--nav-current-fg`, for example as a
68
+ solid selected pill:
69
+
70
+ ```css
71
+ .app-sidebar {
72
+ --nav-current-bg: var(--state-selected);
73
+ --nav-current-fg: var(--state-selected-fg);
74
+ }
75
+ ```
76
+
77
+ Keep the pair's contrast: a brand-colored ink on a tinted fill falls under
78
+ 4.5:1 on several light themes.
79
+
56
80
  ## Responsive: navbar + drawer
57
81
 
58
82
  There is no collapse/toggler mechanism. For a responsive navigation, keep the
@@ -16,23 +16,62 @@ filled while the control remains fully functional.
16
16
  | `.rating[role="img"]` | Component | Read-only display of a value. |
17
17
  | `.sm` / `.lg` | Size | Smaller or larger star geometry. |
18
18
 
19
+ ## Anatomy
20
+
21
+ ```text
22
+ fieldset.field
23
+ ├── legend.field-label names the group
24
+ └── .rating
25
+ └── input[type="radio"] ×1..N, ascending values, aria-label each
26
+
27
+ .rating[role="img"] empty; aria-label and --rating-value
28
+ ```
29
+
30
+ ## Rate this item
31
+
19
32
  ```html demo
20
33
  <fieldset class="field">
21
- <legend class="field-label">Rate your experience</legend>
34
+ <legend class="field-label">Rate this item</legend>
22
35
  <div class="rating">
23
- <input type="radio" name="experience" value="1" aria-label="1 star" />
24
- <input type="radio" name="experience" value="2" aria-label="2 stars" />
25
- <input type="radio" name="experience" value="3" aria-label="3 stars" checked />
26
- <input type="radio" name="experience" value="4" aria-label="4 stars" />
27
- <input type="radio" name="experience" value="5" aria-label="5 stars" />
36
+ <input type="radio" name="item" value="1" aria-label="1 star" />
37
+ <input type="radio" name="item" value="2" aria-label="2 stars" />
38
+ <input type="radio" name="item" value="3" aria-label="3 stars" checked />
39
+ <input type="radio" name="item" value="4" aria-label="4 stars" />
40
+ <input type="radio" name="item" value="5" aria-label="5 stars" />
28
41
  </div>
29
42
  </fieldset>
30
43
  ```
31
44
 
32
45
  Use a visible `<legend>` to name the group and an `aria-label` on every radio
33
- to name its value. Add `required` to the radios when the form must receive a
34
- rating. In forced-colors mode the stars deliberately return to native platform
35
- radios so checked and focus states remain unambiguous.
46
+ to name its value. In forced-colors mode the stars deliberately return to
47
+ native platform radios so checked and focus states remain unambiguous.
48
+
49
+ ## Required rating
50
+
51
+ Add `required` to the radios. With [form validation](../forms/validation.md),
52
+ the `.field-error` appears once the reader leaves the stars empty or submits,
53
+ never on page load, and picking a star clears it.
54
+
55
+ ```html demo
56
+ <form class="stack needs-validation" data-enhance="validation" novalidate>
57
+ <fieldset class="field">
58
+ <legend class="field-label">Rate your stay</legend>
59
+ <div class="rating">
60
+ <input type="radio" name="stay" value="1" aria-label="1 star" required aria-describedby="stay-error" />
61
+ <input type="radio" name="stay" value="2" aria-label="2 stars" required aria-describedby="stay-error" />
62
+ <input type="radio" name="stay" value="3" aria-label="3 stars" required aria-describedby="stay-error" />
63
+ <input type="radio" name="stay" value="4" aria-label="4 stars" required aria-describedby="stay-error" />
64
+ <input type="radio" name="stay" value="5" aria-label="5 stars" required aria-describedby="stay-error" />
65
+ </div>
66
+ <span class="field-error" id="stay-error">Pick a rating to continue.</span>
67
+ </fieldset>
68
+ <div class="cluster">
69
+ <button class="btn primary" type="submit">Send review</button>
70
+ </div>
71
+ </form>
72
+ ```
73
+
74
+ ## Sizes and intents
36
75
 
37
76
  Intent classes change the active color without changing the interaction model.
38
77
 
@@ -69,9 +108,9 @@ value; without `role="img"` nothing is drawn, so a display cannot ship
69
108
  without an accessible name. Do not present a value with disabled radios.
70
109
 
71
110
  ```html demo
72
- <p>
73
- <span class="rating" role="img" aria-label="4.5 out of 5 stars" style="--rating-value: 4.5"></span>
74
- 4.5 from 312 reviews
111
+ <p class="cluster">
112
+ <span class="rating" role="img" aria-label="4.6 out of 5 stars" style="--rating-value: 4.6"></span>
113
+ <span><strong>4.6</strong> out of 5 from 128 reviews</span>
75
114
  </p>
76
115
 
77
116
  <span class="rating sm primary" role="img" aria-label="7 out of 10" style="--rating-value: 7; --rating-max: 10"></span>
@@ -81,6 +120,65 @@ Stars line up with an input `.rating` of the same size, and `.sm`, `.lg` and
81
120
  intent classes apply as above. The fill follows the writing direction. In
82
121
  forced-colors mode the filled share is painted in system colors.
83
122
 
123
+ ## In context
124
+
125
+ Stars sit at the scale of the text and controls around them: a form field with
126
+ help text, a review summary, a review line, a row beside a field and a button.
127
+
128
+ ```html demo
129
+ <div class="stack">
130
+ <fieldset class="field">
131
+ <legend class="field-label">Rate this release</legend>
132
+ <div class="rating">
133
+ <input type="radio" name="release" value="1" aria-label="1 star" />
134
+ <input type="radio" name="release" value="2" aria-label="2 stars" />
135
+ <input type="radio" name="release" value="3" aria-label="3 stars" />
136
+ <input type="radio" name="release" value="4" aria-label="4 stars" checked />
137
+ <input type="radio" name="release" value="5" aria-label="5 stars" />
138
+ </div>
139
+ <small class="field-help">How did this version work for you?</small>
140
+ </fieldset>
141
+
142
+ <p class="cluster">
143
+ <span class="rating sm" role="img" aria-label="4.6 out of 5" style="--rating-value: 4.6"></span>
144
+ <strong>4.6</strong> <span class="muted">· 128 reviews</span>
145
+ </p>
146
+
147
+ <p class="cluster">
148
+ <span class="rating" role="img" aria-label="3.5 out of 5" style="--rating-value: 3.5"></span>
149
+ Great docs, slow build.
150
+ </p>
151
+
152
+ <div class="cluster">
153
+ <input class="input" style="inline-size: 10rem" aria-label="Name" placeholder="Name" />
154
+ <span class="rating" role="img" aria-label="4 out of 5" style="--rating-value: 4"></span>
155
+ <button class="btn" type="button">Send</button>
156
+ </div>
157
+ </div>
158
+ ```
159
+
160
+ ## Star shapes
161
+
162
+ `--rating-star` draws a star and `--rating-star-empty` an empty one; the empty
163
+ shape is the filled one unless set. An outline makes empty and filled differ by
164
+ shape, not only by color; give it an ink that reads as a line, such as
165
+ `--text-subtle`. The same hooks draw any other symbol, a heart here, in the
166
+ page ink.
167
+
168
+ ```html demo
169
+ <div class="stack">
170
+ <span class="rating" role="img" aria-label="3.5 out of 5"
171
+ style="--rating-value: 3.5; --rating-empty: var(--text-subtle); --rating-star-empty: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%222 2 16 16%22%3E%3CclipPath id=%22c%22%3E%3Cpath d=%22M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 0 0 .95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 0 0-.364 1.118l1.07 3.292c.3.922-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 0 0-1.175 0l-2.8 2.034c-.783.57-1.838-.196-1.539-1.118l1.07-3.292a1 1 0 0 0-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 0 0 .951-.69l1.07-3.292Z%22/%3E%3C/clipPath%3E%3Cpath d=%22M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 0 0 .95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 0 0-.364 1.118l1.07 3.292c.3.922-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 0 0-1.175 0l-2.8 2.034c-.783.57-1.838-.196-1.539-1.118l1.07-3.292a1 1 0 0 0-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 0 0 .951-.69l1.07-3.292Z%22 fill=%22none%22 stroke=%22black%22 stroke-width=%222.4%22 clip-path=%22url(%23c)%22/%3E%3C/svg%3E')"></span>
172
+ <span class="rating" role="img" aria-label="4 out of 5"
173
+ style="--rating-value: 4; --rating-color: var(--text); --rating-star: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M12 21s-7.5-4.6-9.6-9.2C.9 8.4 3 4.5 6.6 4.5c2.1 0 3.6 1.2 4.4 2.6.8-1.4 2.3-2.6 4.4-2.6 3.6 0 5.7 3.9 4.2 7.3C19.5 16.4 12 21 12 21z%22/%3E%3C/svg%3E')"></span>
174
+ </div>
175
+ ```
176
+
177
+ Set the hooks on the `.rating` element or in a rule that targets it: the
178
+ component declares its defaults there, so a value set on an ancestor is
179
+ overridden. A browser without `mask-composite` (Chromium before 120) draws
180
+ custom empty stars of a read-only display in the filled shape.
181
+
84
182
  ### Hooks
85
183
 
86
184
  - `--rating-size` — size of each star; `.sm` and `.lg` set this hook.
@@ -88,5 +186,6 @@ forced-colors mode the filled share is painted in system colors.
88
186
  - `--rating-color` — star color. Prefer an intent class for semantic color.
89
187
  - `--rating-empty` — color of unselected stars; use a surface or border token.
90
188
  - `--rating-star` — mask image used to draw a star; override it when a strict CSP disallows data URLs.
189
+ - `--rating-star-empty` — mask image of an empty star; follows `--rating-star` unless set.
91
190
  - `--rating-value` — display only: the value shown, fractions allowed.
92
191
  - `--rating-max` — display only: the number of stars.