@sdxc/ui 2026.10.12 → 2026.10.14

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 (107) hide show
  1. package/README.md +524 -668
  2. package/dist/animations/transitions.d.ts +45 -20
  3. package/dist/animations/transitions.js +108 -35
  4. package/dist/behaviors/announcer.js +2 -1
  5. package/dist/behaviors/toaster.js +2 -1
  6. package/dist/components/accordion.js +5 -9
  7. package/dist/components/alert-dialog.js +3 -3
  8. package/dist/components/alert.js +11 -2
  9. package/dist/components/attachment.js +1 -1
  10. package/dist/components/badge.js +2 -1
  11. package/dist/components/breadcrumbs.js +17 -9
  12. package/dist/components/bubble.js +6 -5
  13. package/dist/components/button.d.ts +14 -0
  14. package/dist/components/button.js +61 -20
  15. package/dist/components/calendar.js +12 -8
  16. package/dist/components/card.d.ts +5 -3
  17. package/dist/components/card.js +32 -14
  18. package/dist/components/carousel.js +4 -6
  19. package/dist/components/chart.js +5 -4
  20. package/dist/components/checkbox.js +2 -2
  21. package/dist/components/color-picker.js +8 -11
  22. package/dist/components/color-slider.js +16 -5
  23. package/dist/components/color-swatch-picker.js +7 -4
  24. package/dist/components/color-wheel.js +7 -9
  25. package/dist/components/combobox.js +5 -1
  26. package/dist/components/command.d.ts +3 -3
  27. package/dist/components/command.js +25 -28
  28. package/dist/components/context-menu.js +4 -4
  29. package/dist/components/date-field.js +2 -1
  30. package/dist/components/date-picker.js +12 -16
  31. package/dist/components/description.js +2 -2
  32. package/dist/components/dialog.js +19 -15
  33. package/dist/components/disclosure.js +15 -17
  34. package/dist/components/drawer.d.ts +5 -5
  35. package/dist/components/drawer.js +38 -33
  36. package/dist/components/drop-indicator.js +4 -10
  37. package/dist/components/empty.js +13 -6
  38. package/dist/components/field-error.js +2 -1
  39. package/dist/components/file-trigger.js +7 -10
  40. package/dist/components/grid-list.js +15 -16
  41. package/dist/components/group.js +5 -6
  42. package/dist/components/heading.js +2 -1
  43. package/dist/components/hover-card.js +4 -5
  44. package/dist/components/image-placeholder.js +17 -12
  45. package/dist/components/index.d.ts +1 -0
  46. package/dist/components/index.js +1 -0
  47. package/dist/components/input.js +8 -11
  48. package/dist/components/item.js +4 -7
  49. package/dist/components/keyboard.js +9 -9
  50. package/dist/components/link-button.js +26 -8
  51. package/dist/components/listbox.d.ts +3 -2
  52. package/dist/components/listbox.js +9 -8
  53. package/dist/components/menu.js +6 -6
  54. package/dist/components/menubar.js +6 -5
  55. package/dist/components/message-scroller.js +4 -6
  56. package/dist/components/message.js +2 -2
  57. package/dist/components/meter.js +2 -2
  58. package/dist/components/modal.d.ts +2 -2
  59. package/dist/components/modal.js +12 -24
  60. package/dist/components/navigation-menu.js +5 -4
  61. package/dist/components/number-field.js +6 -6
  62. package/dist/components/overlay-arrow.js +2 -2
  63. package/dist/components/pagination.js +3 -1
  64. package/dist/components/popover.js +7 -19
  65. package/dist/components/progress-bar.js +2 -2
  66. package/dist/components/range-calendar.js +5 -3
  67. package/dist/components/resizable.js +8 -3
  68. package/dist/components/search-field.js +7 -7
  69. package/dist/components/select.js +26 -39
  70. package/dist/components/sheet.js +30 -22
  71. package/dist/components/shortcut-list.js +2 -2
  72. package/dist/components/sidebar.js +24 -22
  73. package/dist/components/slider.d.ts +3 -3
  74. package/dist/components/slider.js +18 -6
  75. package/dist/components/switch.js +2 -2
  76. package/dist/components/table.d.ts +15 -2
  77. package/dist/components/table.js +36 -14
  78. package/dist/components/tag-group.js +10 -5
  79. package/dist/components/text.js +2 -2
  80. package/dist/components/time-field.js +2 -1
  81. package/dist/components/toast.js +5 -2
  82. package/dist/components/toggle-button.js +28 -12
  83. package/dist/components/tree.js +9 -5
  84. package/dist/components/typeset.js +5 -2
  85. package/dist/components/youtube-embed.d.ts +35 -0
  86. package/dist/components/youtube-embed.js +29 -0
  87. package/dist/mixins/carousel-controls.js +11 -15
  88. package/dist/mixins/clear-field.js +4 -5
  89. package/dist/mixins/context-menu.js +5 -8
  90. package/dist/mixins/grid-list-keys.js +5 -2
  91. package/dist/mixins/listbox-keys.js +1 -1
  92. package/dist/mixins/message-follow.js +7 -13
  93. package/dist/mixins/treeKeys.js +5 -3
  94. package/dist/styles/floating-surface.d.ts +62 -14
  95. package/dist/styles/floating-surface.js +67 -10
  96. package/dist/styles/hit-area.d.ts +36 -0
  97. package/dist/styles/hit-area.js +48 -0
  98. package/dist/styles/index.d.ts +1 -0
  99. package/dist/styles/index.js +1 -0
  100. package/dist/styles/output-caption-text.d.ts +3 -2
  101. package/dist/styles/output-caption-text.js +4 -3
  102. package/dist/styles/range-thumb-appearance.js +17 -18
  103. package/dist/utils/glyph-edges.d.ts +24 -0
  104. package/dist/utils/glyph-edges.js +46 -0
  105. package/package.json +5 -4
  106. package/src/reset.css +4 -1
  107. package/src/theme.css +49 -2
package/README.md CHANGED
@@ -2,30 +2,23 @@
2
2
 
3
3
  Styled, accessible `remix/component` components rendered as server HTML.
4
4
 
5
- Every component is a plain function taking a `Handle<Props>` and rendered through JSX, with
6
- variants, states and colors driven by a `data-*` attribute contract and a set of `--ui-*`
7
- semantic color variables applied through `css()` mixins.
8
-
9
- Baseline behavior comes from the platform itself — `<dialog>`, the Popover API, Invoker
10
- Commands, `<details>` and native form controls — so a page built from these components works
11
- before, and without, any client JavaScript.
12
-
13
5
  ## Installation
14
6
 
15
7
  ```bash
16
8
  npm add @sdxc/ui
17
9
  ```
18
10
 
19
- Components render through `remix`, draw their built-in glyphs from
20
- [`@sdxc/icons`](https://www.npmjs.com/package/@sdxc/icons), and read their theme variables
21
- from [`@sdxc/u`](https://www.npmjs.com/package/@sdxc/u). All three install alongside this
22
- package.
11
+ Components render through `remix`, draw their glyphs from
12
+ [`@sdxc/icons`](https://www.npmjs.com/package/@sdxc/icons), and build on
13
+ [`@sdxc/u`](https://www.npmjs.com/package/@sdxc/u); all three install alongside this package.
23
14
 
24
15
  ## Usage
25
16
 
26
- ### Render A Component
17
+ ### Render a component
27
18
 
28
- Every component takes a `Handle<Props>` and returns a render closure, and is used as JSX:
19
+ Every component takes a `Handle<Props>` and renders through JSX. Props such as `color` become
20
+ `data-*` attributes that the component's own `css()` styles key off, so this is static HTML with no
21
+ client JavaScript:
29
22
 
30
23
  ```tsx
31
24
  import type { Handle } from "remix/component";
@@ -41,13 +34,13 @@ export function OrderStatus(handle: Handle<{ paid: boolean }>) {
41
34
  }
42
35
  ```
43
36
 
44
- That is static server HTML: `color` becomes `data-color`, and a CSS attribute selector
45
- paints the rest — no hydration, no client JavaScript.
37
+ The package ships no copy: every visible and accessible string is a prop or child you supply.
46
38
 
47
- ### Set Up The Stylesheets
39
+ ### Load the stylesheets
48
40
 
49
- Import the reset and the theme ahead of your own styles, then define the five palette
50
- scales the theme derives every semantic variable from:
41
+ Import the reset and the theme ahead of your own styles, then define the five palette scales
42
+ (`brand`, `neutral`, `danger`, `warning`, `success`, each `50` through `950`) the theme derives
43
+ every `--ui-*` variable from:
51
44
 
52
45
  ```css
53
46
  @import "@sdxc/ui/reset.css";
@@ -57,53 +50,38 @@ scales the theme derives every semantic variable from:
57
50
  --ui-color-brand-50: oklch(0.97 0.02 250);
58
51
  --ui-color-brand-500: oklch(0.6 0.18 250);
59
52
  --ui-color-brand-950: oklch(0.22 0.08 250);
60
-
61
- /* the same 50-950 shape for neutral, danger, warning and success */
62
53
  }
63
54
  ```
64
55
 
65
- `reset.css` zeroes margins, sets `box-sizing: border-box`, and lets form controls inherit
66
- font and color. Every selector sits inside `:where()` for zero specificity, and the file
67
- opens with `@layer base, rmx;` so component styles always win. It leaves `<dialog>`'s
68
- `::backdrop` and the `dialog`/`[popover]` margins alone, since overlays rely on that native
69
- centering — an app shipping an equivalent reset can import `theme.css` on its own.
56
+ `reset.css` declares `@layer base, rmx;`, so component styles always win over it. `theme.css` is light
57
+ on `:root`, dark under a `.dark` class on `<html>`, and follows `prefers-color-scheme` under `.system`.
70
58
 
71
- `theme.css` is the `--ui-*` semantic layer: a light `:root` block, a `.dark` class on
72
- `<html>` for forced dark mode, a `.system` class that follows `prefers-color-scheme`, and
73
- the `--ui-chart-1` through `--ui-chart-8` categorical sequence for multi-series charts. Two
74
- apps supplying the same scales render the same design, because components read the derived
75
- contract rather than any raw scale value.
59
+ ### Open a dialog with a plain button
76
60
 
77
- ### Open A Dialog Without JavaScript
78
-
79
- Overlays ride native platform mechanisms, so a trigger is an ordinary button:
61
+ Overlays ride native `<dialog>`, the Popover API and
62
+ [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API), so a
63
+ trigger is an ordinary button and the page tracks no open state:
80
64
 
81
65
  ```tsx
82
66
  import { Button, Dialog } from "@sdxc/ui";
83
67
 
84
- <Button commandfor="invite-teammate" command="show-modal">
85
- {t("team.invite")}
68
+ <Button commandfor="invite" command="show-modal">
69
+ Invite
86
70
  </Button>
87
- <Dialog id="invite-teammate">
71
+ <Dialog id="invite">
88
72
  <Dialog.Header>
89
- <Dialog.Title>{t("team.inviteTitle")}</Dialog.Title>
73
+ <Dialog.Title>Invite a teammate</Dialog.Title>
90
74
  </Dialog.Header>
91
75
  <Dialog.Footer>
92
- <Dialog.Close>{t("actions.close")}</Dialog.Close>
76
+ <Dialog.Close>Close</Dialog.Close>
93
77
  </Dialog.Footer>
94
78
  </Dialog>;
95
79
  ```
96
80
 
97
- The pairing is
98
- [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
99
- against the native
100
- [`<dialog>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog)
101
- element, so the page needs no open-state bookkeeping.
102
-
103
- ### Add Behavior With A Mixin
81
+ ### Add behavior with a mixin
104
82
 
105
- A widget that wants interactivity gets it from a mixin applied through `mix` inside a
106
- hydrated island. The components themselves stay pure UI:
83
+ Components never hydrate. Interactivity comes from a mixin applied through `mix` inside your own
84
+ `clientEntry` island, often paired with a headless behavior class that holds the state:
107
85
 
108
86
  ```tsx
109
87
  import type { Handle } from "remix/component";
@@ -112,348 +90,364 @@ import { clientEntry } from "remix/component";
112
90
 
113
91
  import { Command } from "@sdxc/ui";
114
92
  import { FilterModel } from "@sdxc/ui/behaviors";
115
- import { commandFilter } from "@sdxc/ui/mixins";
116
-
117
- type Props = { pages: Array<{ id: string; title: string }> };
93
+ import { commandFilter, commandKeys } from "@sdxc/ui/mixins";
118
94
 
119
95
  export default clientEntry(
120
- "/app/components/search-palette.tsx#default",
121
- function SearchPalette(handle: Handle<Props>) {
96
+ "/components/search-palette.tsx#default",
97
+ function SearchPalette(handle: Handle<{ pages: Array<{ id: string; title: string }> }>) {
122
98
  let model = new FilterModel();
123
99
 
124
100
  return () => (
125
- <Command mix={commandFilter(model)}>
126
- <Command.Input placeholder={t("search.placeholder")} />
101
+ <Command mix={[commandFilter(model), commandKeys(model)]}>
102
+ <Command.Input placeholder="Search pages" />
127
103
  <Command.List>
128
104
  {handle.props.pages.map((page) => (
129
105
  <Command.Item key={page.id} value={page.title}>
130
- {page.title}
106
+ <a href={`/pages/${page.id}`}>{page.title}</a>
131
107
  </Command.Item>
132
108
  ))}
133
109
  </Command.List>
134
- <Command.Empty>{t("search.empty")}</Command.Empty>
110
+ <Command.Empty>No results</Command.Empty>
135
111
  </Command>
136
112
  );
137
113
  },
138
114
  );
139
115
  ```
140
116
 
141
- Only the island that applies a mixin needs a `clientEntry`; a page that sticks to baseline
142
- behavior ships no library JavaScript at all. Every example here writes user-facing copy as
143
- `t(key)`, standing in for whatever localization function your app has — the library ships no
144
- copy of its own, so each visible or accessible string is a prop you supply.
117
+ A page that sticks to baseline behavior ships no library JavaScript at all.
145
118
 
146
119
  ## API
147
120
 
148
- Every export carries its own JSDoc, so hover and autocomplete give the full signature. What
149
- follows is the index.
150
-
151
- | Import | Contains |
152
- | --------------------- | ------------------------------------------------------------------------------------- |
153
- | `@sdxc/ui` | Every component and its compound parts. |
154
- | `@sdxc/ui/animations` | CSS-only motion factories plus the shared `durations`/`easings` tokens. |
155
- | `@sdxc/ui/behaviors` | Headless, DOM-free state classes built on `TypedEventTarget`. |
156
- | `@sdxc/ui/mixins` | Opt-in DOM behaviors applied through a component's `mix` prop. |
157
- | `@sdxc/ui/styles` | Shared style recipes composed inside a `mix` array. |
158
- | `@sdxc/ui/utils` | Framework-free color, scale, path, geometry and field helpers, plus the shared types. |
159
- | `@sdxc/ui/reset.css` | The base reset. |
160
- | `@sdxc/ui/theme.css` | The `--ui-*` semantic variable layer. |
161
-
162
- ### The Shared Contract
163
-
164
- One contract covers the whole catalog, which is what keeps the component index below to a
165
- line each.
166
-
167
- **Props become `data-*` attributes.** `color`, `variant`, `size` and their neighbours are
168
- written onto the host element, and every style rule keys off them. Wherever a `color` prop
169
- appears it takes one of `"brand"`, `"neutral"`, `"success"`, `"warning"` or `"danger"` — the
170
- `SemanticColor` union — and the theme resolves the actual values.
171
-
172
- **Compound parts hang off the root.** `Dialog.Header`, `Card.Title`, `Chart.Legend.Item`:
173
- each is its own component with its own props, and `data-slot` marks its role in the layout.
174
-
175
- **`mix` styles the host.** It takes a `css()` call, a style recipe, an animation factory, or
176
- an array of them. A wrapper rendering several elements takes a `parts` prop instead, one
177
- `mix` per named part.
178
-
179
- **Every measurement is an overridable variable**, emitted as
180
- `var(--ui-<component>-<property>, <default>)`, so retuning a component is one declaration.
181
- One radius scale is shared across every rounded surface — `--ui-radius-none` (`0px`), `-sm`
182
- (`0.25rem`), `-md` (`0.375rem`), `-lg` (`0.5rem`), `-xl` (`0.75rem`), `-full` (`9999px`) —
183
- and well over a hundred more are scoped to a single component each, among them
184
- `--ui-sidebar-width` (`16rem`), `--ui-sheet-size` (`24rem`), `--ui-slider-thumb-size`
185
- (`1.25rem`), `--ui-popover-offset` (`0.5rem`) and `--ui-chart-line-width` (`2px`). Each is
186
- named in the JSDoc of the component that reads it.
187
-
188
- **Accessibility media features are handled centrally.** `prefers-reduced-motion: reduce`
189
- collapses every animation factory to an opacity-only fade, `prefers-contrast: more` promotes
190
- each color role's border to its stronger value, and `prefers-reduced-transparency: reduce`
191
- keeps `backdrop-filter` blur additive over an already-opaque background.
192
-
193
- ### Components: Forms
194
-
195
- - `Form` — the wrapper a multi-field layout starts from; set `issues` from a `parseSafe`
196
- result and each field beneath reads its own errors by name.
197
- - `Label`, `Description`, `FieldError` — a control's caption, its supporting copy as a `<p>`
198
- for `aria-describedby`, and its validation message with a stable id.
199
- - `Input`, `TextArea` — a single-line native text field (the foundation the other text
200
- controls build on) and a multi-line one that grows through `field-sizing: content`.
201
- - `TextField`, `DateField`, `TimeField` — labeled, described, validated wrappers around a
202
- text, date, or time input.
203
- - `NumberField`, `OtpField` — a number input framed with decrement and increment buttons,
204
- and a one-time-code field with a numeric keyboard and the platform's autofill hint.
205
- - `Checkbox`, `CheckboxGroup`, `RadioGroup`, `Switch`, `ToggleButton` — native checked-state
206
- controls: a styled checkbox, the landmark grouping a run of them, mutually exclusive
207
- radios sharing one name, an on/off pill, and a button carrying `aria-pressed`.
208
- - `Slider`, `Meter`, `ProgressBar` — a range input with a fill track and an `<output>`, and
209
- styled native `<meter>` and `<progress>`; an unset `value` on the last drops into the
210
- indeterminate state.
211
- - `Select`, `ComboBox`, `SearchField` — a native `<select>` upgraded to customizable-select
212
- rendering wherever the browser resolves `appearance: base-select`, a text control paired
213
- with a `<datalist>`, and a `<search>` landmark around a `type="search"` control.
214
- - `FileTrigger`, `DropZone` — a pressable surface opening the file picker, and a dashed drop
215
- target, both backed by a native file input.
216
-
217
- ### Components: Overlays And Menus
218
-
219
- Each surface rides one of three native mechanisms: `<dialog>` with Invoker Commands, the
220
- [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) with CSS anchor
221
- positioning, or a custom `--ui-*` command answered by a mixin.
222
-
223
- - `Dialog` — a modal built on native `<dialog>`, opened and closed through
224
- `commandfor`/`command`.
225
- - `AlertDialog` — an interruptive modal sealed against light dismiss
226
- (`closedby="closerequest"`).
227
- - `Modal`, `Drawer`, `Sheet` — `Dialog` presets: pop-in motion, an edge-docked panel, and a
228
- fixed inline-side column.
229
- - `Confirm` — a two-control confirmation prompt in one call; pass `form` and the confirming
230
- control submits a real form.
231
- - `Popover`, `Tooltip`, `HoverCard` — a surface anchored to whatever invoker opened it, a
232
- small label revealed by `:hover`/`:focus-visible` on the preceding sibling, and a detail
233
- panel revealed by `:hover`/`:focus-within` on a shared root.
234
- - `Menu`, `Menubar`, `ContextMenu` — a popover-based menu surface, a horizontal row of
235
- triggers each opening one, and a menu meant to open at a right-click's pointer position.
236
- - `NavigationMenu` — a row of navigation triggers, each a link or a button opening a panel
237
- of related links.
238
- - `Command` — a bordered panel listing selectable rows for searching among a set of actions.
239
- - `OverlayArrow` — a pointer glyph anchoring a floating surface back to its trigger.
240
-
241
- ### Components: Navigation And Data
242
-
243
- - `Button` — a single immediate action; `isPending` swaps content for a spinner while
244
- keeping the footprint.
245
- - `Link`, `NavLink`, `LinkButton` — an inline anchor kept underlined, a navigation link
246
- colored by a semantic role, and a link styled as a button.
247
- - `Tabs` — tabs whose active view comes from routing: whichever `.Tab` points at the current
248
- page carries `aria-selected="true"`.
249
- - `Breadcrumbs`, `Pagination` — a trail of parent sections, and a landmark for moving
250
- between pages of results.
251
- - `Sidebar` — an application shell's navigation rail; collapse rides one checkbox's native
252
- `:checked` state.
253
- - `Disclosure`, `Accordion` — a single expand/collapse section built on `<details>`, and a
254
- divider-separated stack of them.
255
- - `Table` — tabular data whose column headers become sort links and whose trailing row
256
- becomes a load-more link, both from URLs you compute.
257
- - `GridList`, `Tree`, `ListBox` — an interactive row list, a hierarchical list of nested
258
- `<details>`, and a run of selectable rows built from visually-hidden inputs.
259
- - `SelectionIndicator`, `DropIndicator` — a marker reserving its own layout slot for the
260
- current selection, and a bar marking a drop position.
261
-
262
- ### Components: Feedback
263
-
264
- - `Alert`, `Toast` — an inline status panel with `role="alert"` and a configurable
265
- politeness, and a transient notification whose `.Region` stacks the queue.
266
- - `Badge`, `TagGroup` — a compact status pill, and a labeled set of pills each optionally
267
- paired with a remove control.
268
- - `Skeleton`, `Spinner`, `Empty` — a loading placeholder block, a busy indicator inside a
269
- `role="progressbar"` host, and a dashed placeholder for a section with nothing to show.
270
-
271
- ### Components: Color
272
-
273
- - `ColorSwatch` — a preview box for one CSS color, backed by a checkerboard so translucent
274
- values read correctly.
275
- - `ColorArea`, `ColorWheel`, `ColorSlider` — a 2D saturation/brightness picker from two
276
- overlaid range inputs, a circular hue picker from one, and a single-channel (`hue`,
277
- `saturation`, `lightness`, `alpha`) control.
278
- - `ColorSwatchPicker` — mutually exclusive preset colors built from native radios.
279
- - `ColorField`, `ColorPicker` — a labeled, described, validated color text field with a live
280
- swatch, and that field extended with a trigger and a popover-hosted picking surface.
281
-
282
- ### Components: Charts And Conversation
283
-
284
- - `Chart` — the coordinate space every Cartesian series renders into, with `.Line`, `.Area`,
285
- `.Pie`, `.Bar`, `.Legend` and `.Tooltip` parts.
286
- - `Message`, `MessageScroller` — a conversational turn laid out with grid areas keyed off
287
- each part's `data-slot`, and a scrollable log frame whose content is a `role="log"`.
288
- - `Bubble`, `Marker`, `Attachment` — the framed surface inside a turn's content slot, an
289
- inline row calling out a small event between turns, and a card for one attached file.
290
-
291
- ### Components: Layout And Content
292
-
293
- - `Card` — a bordered, tinted panel grouping a header, content, and footer actions.
294
- - `ImagePlaceholder` — a fixed-size image-with-fallback box; `Avatar` and `Logo` are its
295
- circular and rounded-square presets.
296
- - `AspectRatio`, `Resizable`, `ScrollArea`, `Carousel` — a ratio lock, a split-pane layout
297
- of panels and handles, a bordered scrollable region, and a slide collection riding CSS
298
- scroll snap.
299
- - `Group`, `Section`, `Separator`, `Toolbar` — a cluster of related controls, a grouping
300
- inside a listbox or menu, a divider, and a strip of controls along one axis.
301
- - `Item` — a single-line row with leading media, title and description, and trailing
302
- actions.
303
- - `Text`, `Header`, `Keyboard`, `Typeset` — muted body copy, an uppercase section label in a
304
- `<header>`, a shortcut hint in a `<kbd>`, and a typography layer for already-rendered
305
- markup with `docs`, `chat` and `reading` presets.
306
- - `ShortcutList` — a two-column `<dl>` pairing each action with the key caps that run it,
307
- for a keyboard-shortcuts panel.
308
- - `Highlight` — text split into `{ text, match }` segments, each match a tinted `<mark>`
309
- that keeps the surrounding color and weight, for search results and filtered lists.
310
- - `HeadingScope`, `Heading` — an ambient heading-depth scope and the heading that reads it.
311
- - `SharedElement` — a host carrying a stable view-transition identity across page loads.
312
- - `Calendar`, `RangeCalendar`, `DatePicker`, `DateRangePicker` — a month grid for one day or
313
- a connected range, and either extended with a trigger and a popover-hosted calendar.
314
- Rendered with no children, `Calendar` falls back to a native `<input type="date">`.
121
+ | Import | Contains |
122
+ | --------------------- | ------------------------------------------------------------------- |
123
+ | `@sdxc/ui` | Every component and its compound parts. |
124
+ | `@sdxc/ui/mixins` | Opt-in DOM behaviors applied through `mix`. |
125
+ | `@sdxc/ui/behaviors` | Headless state classes built on `TypedEventTarget`. |
126
+ | `@sdxc/ui/animations` | CSS-only motion factories and the `durations`/`easings` tokens. |
127
+ | `@sdxc/ui/styles` | Style recipes composed inside a `mix` array. |
128
+ | `@sdxc/ui/utils` | Framework-free color, chart, geometry, key and DOM helpers; types. |
129
+ | `@sdxc/ui/reset.css` | The base reset in `@layer base`. |
130
+ | `@sdxc/ui/theme.css` | The `--ui-*` semantic variables and the `--ui-chart-1`…`8` palette. |
131
+
132
+ Every export carries JSDoc, so the editor shows each full signature.
133
+
134
+ ### Component contract
135
+
136
+ - A component's props type lives on its namespace (`Button.Props`, `Dialog.TitleProps`), and
137
+ compound parts hang off the root (`Dialog.Header`, `Chart.Legend.Item`).
138
+ - `color` takes a `SemanticColor`: `"brand"`, `"neutral"`, `"success"`, `"warning"` or `"danger"`.
139
+ - `mix` styles the host. A wrapper rendering several elements also takes `parts`, one `mix` per
140
+ named part.
141
+ - Every measurement reads `var(--ui-<component>-<property>, <default>)`, plus the shared
142
+ `--ui-radius-*` scale, so one declaration retunes a component.
143
+ - Title slots (`Dialog.Title`, `Alert.Title`, `Heading`) render the heading level of the nearest
144
+ `HeadingScope`.
145
+ - `prefers-reduced-motion`, `prefers-contrast: more` and `prefers-reduced-transparency` are handled
146
+ by the animations and the theme.
147
+ - Small controls reach a pointer target of `--ui-target-size` (24px, 44px on coarse pointers).
148
+ - In development, a missing accessible name or id linkage (an icon-only `Button`, a `Dialog` without
149
+ `id`, a `Command.Item` without `value`) logs a `console.warn`.
150
+
151
+ ### Components: forms
152
+
153
+ - `Form` — a `<form>` taking `issues` from a `parseSafe` result; each field beneath reads its own
154
+ errors by `name`.
155
+ - `Label`, `Description`, `FieldError` — a caption, supporting copy for `aria-describedby`, and a
156
+ validation message.
157
+ - `Input`, `TextArea` — native text controls; the area grows with `field-sizing: content`.
158
+ - `TextField`, `DateField`, `TimeField` — labeled, described, validated wrappers around an input.
159
+ - `NumberField`, `OtpField` — a number input with step buttons, and a one-time-code field.
160
+ - `Checkbox`, `CheckboxGroup`, `RadioGroup`, `Switch` — native checked-state controls and their
161
+ groupings.
162
+ - `ToggleButton`, `ToggleButtonGroup` — a button carrying `aria-pressed`, and a row or column of
163
+ them.
164
+ - `Slider`, `Meter`, `ProgressBar` — a range input with a fill and `<output>`, and styled `<meter>`
165
+ and `<progress>` (indeterminate when `value` is unset).
166
+ - `Select`, `ComboBox`, `SearchField` — a native `<select>` with customizable-select styling, a
167
+ text input with a `<datalist>`, and a `<search>` landmark.
168
+ - `FileTrigger`, `DropZone` — a button opening the file picker, and a drop target, both over a
169
+ native file input.
170
+
171
+ ### Components: overlays and menus
172
+
173
+ - `Dialog`, `AlertDialog` — modals on `<dialog>`; the alert variant ignores light dismiss.
174
+ - `Modal`, `Drawer`, `Sheet` — `Dialog` presets: pop-in, edge-docked, and a fixed side column.
175
+ - `Confirm` — a complete confirmation dialog; with `form` its confirm button submits a real form.
176
+ - `Popover`, `Tooltip`, `HoverCard` — an anchored popover, a label shown on hover or focus of the
177
+ preceding sibling, and a detail panel shown on hover or focus within.
178
+ - `Menu`, `Menubar`, `ContextMenu`, `NavigationMenu` — popover menus, a row of menu triggers, a
179
+ pointer-positioned menu, and a row of navigation panels.
180
+ - `Command` — a searchable list of actions with `.Input`, `.List`, `.Item` and `.Empty`.
181
+ - `OverlayArrow` — a pointer from a floating surface back to its trigger.
182
+
183
+ ### Components: navigation and data
184
+
185
+ - `Button` — `color`, `variant`, `size`, and `isPending` to show a spinner at the same size.
186
+ - `Link`, `NavLink`, `LinkButton` — an inline anchor, a navigation link, and a link styled as a
187
+ button.
188
+ - `Tabs` — tabs driven by routing: the `.Tab` pointing at the current page is selected.
189
+ - `Breadcrumbs`, `Pagination`, `Sidebar` — a trail of parents, a pager landmark, and an app shell
190
+ rail whose collapse rides a checkbox's `:checked`.
191
+ - `Disclosure`, `Accordion` — `<details>` sections, alone or stacked.
192
+ - `Table` — a table whose `.Column` takes a sort `href` and whose `.LoadMore` row is a link.
193
+ - `GridList`, `Tree`, `ListBox` — an interactive row list, nested `<details>`, and selectable rows.
194
+ - `SelectionIndicator`, `DropIndicator`, `SentinelRow` — a selection marker, a drop-position bar,
195
+ and a muted row holding a loading or "load more" control.
196
+
197
+ ### Components: feedback
198
+
199
+ - `Alert`, `Toast` — an inline status panel, and a notification stacked by `Toast.Region`.
200
+ - `Badge`, `TagGroup` — a status pill, and a labeled set of removable pills.
201
+ - `Skeleton`, `Spinner`, `Empty` — a loading block, a busy indicator, and an empty-state panel.
202
+
203
+ ### Components: color
204
+
205
+ - `ColorSwatch`, `ColorSwatchPicker` — a color preview, and preset colors as native radios.
206
+ - `ColorArea`, `ColorWheel`, `ColorSlider` — saturation/brightness, hue, and single-channel pickers
207
+ built from range inputs.
208
+ - `ColorField`, `ColorPicker` — a color text field with a live swatch, and that field with a
209
+ popover (`ColorPicker.Dialog`) hosting any of the pickers above.
210
+
211
+ ### Components: charts and conversation
212
+
213
+ - `Chart` — an SVG coordinate space (`width`, `height`, `xDomain`, `yDomain`) for `.Line` and
214
+ `.Area` series, plus standalone `.Bar` and `.Pie`, a `.Legend`, and the `.Tooltip` surface that
215
+ `chartTooltip()` drives; every point is a labeled, focusable marker.
216
+ - `MessageScroller` — a `role="log"` frame with `.Viewport`, `.Content`, `.Item` and a
217
+ jump-to-latest `.Button`.
218
+ - `Message`, `Bubble`, `Marker`, `Attachment` — a turn, its framed content, an inline event between
219
+ turns, and an attached-file card.
220
+
221
+ ### Components: layout and content
222
+
223
+ - `Card`, `Item`, `Group`, `Section`, `Separator`, `Toolbar` — panels, rows, groupings and dividers.
224
+ - `ImagePlaceholder`, `Avatar`, `Logo` — an image with fallback, and its round and rounded-square
225
+ presets.
226
+ - `AspectRatio`, `Resizable`, `ScrollArea`, `Carousel` — a ratio lock, split panes, a scroll region,
227
+ and a scroll-snap slide set.
228
+ - `YouTubeEmbed` — a lazy-loaded 16:9 YouTube player (`videoId`, `start?`, `title`) served from
229
+ `www.youtube-nocookie.com`, which the page's `frame-src` has to allow.
230
+ - `Text`, `Header`, `Keyboard`, `Typeset` — muted copy, a section label, a `<kbd>`, and typography
231
+ for rendered markup (`docs`, `chat`, `reading`).
232
+ - `ShortcutList` — a `<dl>` pairing actions with key caps.
233
+ - `Highlight` — `{ text, match }` segments rendered with each match in a `<mark>`.
234
+ - `HeadingScope`, `Heading` — a heading-depth scope, and the `<h1>`–`<h6>` that reads it.
235
+ - `SharedElement` — a host with a stable view-transition name across page loads.
236
+ - `Calendar`, `RangeCalendar`, `DatePicker`, `DateRangePicker` — month grids for a day or a range,
237
+ and popover pickers around them; `Calendar` without children renders `<input type="date">`.
238
+
239
+ ### Component helpers
240
+
241
+ - `readFormContext(handle): Form.Context | undefined` and
242
+ `resolveFieldIssue(handle, name, errorMessage?): FieldIssueState` — how a custom field joins
243
+ `Form`'s issues.
244
+ - `readAmbientLevel(handle)`, `resolveHeadingLevel(handle, level?)` and `TAG_BY_LEVEL` — how a
245
+ custom heading joins `HeadingScope`.
246
+ - `tabIndicatorMix(orientation, activeIndex, tabSize)` — positions `Tabs.List`'s sliding indicator
247
+ for fixed-size tabs.
315
248
 
316
249
  ### Mixins
317
250
 
318
- A mixin is a `createMixin` adapter attached through `mix`. Each module opens with a doc
319
- comment naming what the platform cannot express on its own and what still works when the
320
- script never runs, so the cost of every behavior stays visible before you apply it.
321
-
322
- | Mixin | Host | What it adds |
323
- | ------------------------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
324
- | `ariaChecked()` | a native checked control | Keeps `aria-checked` following live checkedness, including across a radio group. |
325
- | `attachmentTrigger()` | `Attachment.Trigger` | Makes the whole card one activation target while nested buttons keep their own clicks. |
326
- | `calendarKeys(model)` | `Calendar.Grid` | Arrow/Page/Home/End navigation over a `CalendarModel`, mirrored as roving `tabindex`. |
327
- | `carouselControls()` | `Carousel.Viewport` | Answers `--ui-prev`/`--ui-next`/`--ui-goto` commands as `scrollBy()` calls. |
328
- | `channelSync()` | a `ColorSlider` group | Keeps sibling channel gradients current with each other's live values. |
329
- | `chartTooltip()` | a `Chart` root | Tracks the nearest plotted point to the pointer or focus and fills the sibling `Chart.Tooltip`. |
330
- | `clearField()` | a `SearchField` clear | Empties its own `commandfor` input and reveals itself on mount. |
331
- | `colorAreaDrag()` | `ColorArea` | Drags the root as one 2D gesture across its paired axis inputs. |
332
- | `colorPreview()` | `ColorField` | Updates the paired `ColorSwatch` as a typed value parses. |
333
- | `colorWheelDrag()` | `ColorWheel` | Reshapes the hue input into a ring and drags it as an angular gesture. |
334
- | `comboboxFilter()` | `ComboBox.Input` | As-you-type narrowing through `@remix-run/ui/combobox`. |
335
- | `commandFilter(model)` | `Command` | Filtering against a `FilterModel`, mirrored onto items as `hidden`. |
336
- | `commandKeys(model)` | `Command` | Arrow keys move the active match; Enter activates its nested link or button. |
337
- | `contextMenu(id)` | `ContextMenu.Trigger` | Opens the named popover at the pointer on right-click or the Context Menu key. |
338
- | `copyToClipboard()` | a footer button | Copies the text content of its `commandfor` target. |
339
- | `dismiss(options?)` | an alert or toast host | An auto-dismiss countdown, pausable on hover, plus a `--ui-dismiss` command. |
340
- | `dragReorder(session)` | `GridList` / `Tree` | Pointer reorder against a `DragSession`, computing before/after/on drop position. |
341
- | `dropZone(session)` | `DropZone` | File drag-and-drop acceptance backed by a `DragSession`. |
342
- | `dualRange()` | a two-thumb `Slider` | Keeps paired range inputs ordered, clamping the moved thumb at its partner. |
343
- | `gridListKeys(model)` | `GridList` | The ARIA grid keyboard pattern against a `SelectionModel`. |
344
- | `headingLevelFallback(options)` | an island's heading root | Recovers the ambient heading depth from `data-heading-level` at a hydration boundary. |
345
- | `hotkey(combo)` | any `<dialog>`/`[popover]` | A document-level shortcut opening or closing its host regardless of focus. |
346
- | `keymap(bindings)` | any host | Page-wide shortcuts that stand down in fields, IME composition, and dialogs outside the host. |
347
- | `imageFallback()` | `Avatar` / `Logo` images | Flags a failed image load, including retroactively for cached images. |
348
- | `listboxKeys()` | `ListBox` | Arrow/Home/End/typeahead through `@remix-run/ui/listbox`. |
349
- | `longPress(options?)` | any element | Fires once a pointer holds still past a duration and movement tolerance. |
350
- | `menuKeys(options?)` | `Menu` | The WAI-ARIA menu pattern: roving tabindex, arrows, Home/End, typeahead. |
351
- | `menubarKeys(options?)` | `Menubar` | The WAI-ARIA menubar pattern, handing off into whichever `Menu` opens. |
352
- | `messageFollow(model)` | `MessageScroller.Viewport` | Bridges the viewport to a `ScrollFollowModel`: measurement, scroll intents, pinned state. |
353
- | `otpSlots()` | an `OtpField` group | Moves focus across slots and splits a pasted code. |
354
- | `persist(key)` | a `Sidebar` root | Mirrors the collapsed checkbox into a cookie and answers a `--ui-toggle` command. |
355
- | `pressToggle()` | `ToggleButton` | Flips `aria-pressed` on each click. |
356
- | `rangePreview(model)` | `RangeCalendar.Grid` | Hover and focus range preview against a `CalendarModel`'s pending anchor. |
357
- | `resizeHandle(axis, session)` | `Resizable.Handle` | Pointer resize against a `ResizeSession`, mirrored as a custom property. |
358
- | `stepper(options?)` | `NumberField.Group` | Press-and-hold repeat for the increment and decrement buttons. |
359
- | `tabKeys(options?)` | `Tabs.List` | Delegated arrow/Home/End activation through the shared `@remix-run/ui/tabs` context. |
360
- | `themeToggle(options?)` | any host | Switches `<html>` between light, dark and system through commands, persisted to a cookie. |
361
- | `treeKeys(model)` | `Tree` | The WAI-ARIA tree pattern against a `SelectionModel`, typeahead included. |
362
- | `validate(schema)` | a native form control | Applies a `remix/data-schema` schema through `setCustomValidity()`, mirrored into a `FieldError`. |
363
- | `viewTransition()` | a `SharedElement` island | Bridges a same-document reload to the View Transition API. |
364
- | `trackHostNode(handle)` | inside a mixin | Caches a mixin's live host node across insert and remove, for the mixins above that read the DOM outside render. |
365
- | `whileLive(handle, subscribe)` | inside a mixin | Subscribes a mixin or island to a model, session or frame only while it is live in a document. |
366
-
367
- ### Behavior Classes
368
-
369
- Headless, DOM-free state models. Each is unit-testable on its own, and an island subscribes
370
- to it and re-renders.
371
-
372
- - `Announcer` — a priority-ordered queue of `aria-live` announcements, optionally advancing
373
- on its own once each message has been current for a `hold`.
374
- - `CalendarModel` — the keyboard-focused day, the visible month, and an in-progress range.
375
- - `DragSession` — the dragged item, the drop candidate under the pointer, and the computed
376
- drop position.
377
- - `FilterModel` — query, matched subset, and active match for search-as-you-type.
378
- - `ResizeSession` — resize constraint solving across a panel group, cascading once a
379
- neighbor bottoms out.
380
- - `ScrollFollowModel` — auto-follow pinning, anchor turn, visible messages, and pending
381
- scroll intents.
382
- - `SelectionModel` — a selected-key set with toggle, contiguous-range, and select-all
383
- semantics.
384
- - `Toaster` — a toast queue owning each toast's auto-dismiss timer and pause/resume.
251
+ Each mixin module documents why it needs JavaScript and what still works without it.
252
+
253
+ | Mixin | Host | Adds |
254
+ | ------------------------------- | -------------------------- | ----------------------------------------------------------------------- |
255
+ | `ariaChecked()` | checkbox, switch or radio | `aria-checked` kept in step with the live control. |
256
+ | `attachmentTrigger()` | `Attachment.Trigger` | The whole card as one activation target. |
257
+ | `calendarKeys(model)` | `Calendar.Grid` | Arrow/Page/Home/End navigation over a `CalendarModel`. |
258
+ | `carouselControls()` | `Carousel.Viewport` | `--ui-prev`, `--ui-next` and `--ui-goto` commands. |
259
+ | `channelSync()` | a `ColorSlider` group | Sibling channel gradients that follow each other. |
260
+ | `chartTooltip()` | a chart series | `Chart.Tooltip` filled from the nearest point to pointer or focus. |
261
+ | `clearField()` | `SearchField` clear button | Empties its `commandfor` input. |
262
+ | `colorAreaDrag()` | `ColorArea` | A 2D drag across the paired thumbs. |
263
+ | `colorPreview()` | `ColorField` | The swatch updated as the typed value parses. |
264
+ | `colorWheelDrag()` | `ColorWheel` | An angular drag around the ring. |
265
+ | `comboboxFilter()` | `ComboBox.Input` | As-you-type narrowing. |
266
+ | `commandFilter(model)` | `Command` | Items hidden by a `FilterModel` query. |
267
+ | `commandKeys(model)` | `Command` | Arrow keys over matches; Enter activates the active item's link/button. |
268
+ | `contextMenu(id, options?)` | `ContextMenu.Trigger` | Opens popover `id` at the pointer on right-click or the menu key. |
269
+ | `copyToClipboard()` | a button | Copies the text of its `commandfor` target. |
270
+ | `dismiss(options?)` | an alert or toast | Auto-dismiss countdown paused on hover, plus a `--ui-dismiss` command. |
271
+ | `dragReorder(session)` | `GridList` / `Tree` | Pointer reordering through a `DragSession`. |
272
+ | `dropZone(session)` | `DropZone` | File drag-and-drop through a `DragSession`. |
273
+ | `dualRange()` | a two-thumb `Slider` | Thumbs that cannot cross. |
274
+ | `gridListKeys(model)` | `GridList` | The ARIA grid keyboard pattern over a `SelectionModel`. |
275
+ | `headingLevelFallback(options)` | an island's `HeadingScope` | Reports the page's heading depth to `onLevel` once on attach. |
276
+ | `hotkey(combo)` | a `<dialog>`/`[popover]` | A document-wide shortcut toggling its host. |
277
+ | `imageFallback()` | an `Avatar`/`Logo` image | Shows the fallback when the image fails, cached images included. |
278
+ | `keymap(bindings)` | any host | Page-wide shortcuts that stand down in fields and foreign dialogs. |
279
+ | `listboxKeys()` | `ListBox` | Arrow, Home/End and typeahead navigation. |
280
+ | `longPress(options?)` | any element | Fires after a pointer holds still for `duration`. |
281
+ | `menuKeys(options?)` | `Menu` | The ARIA menu pattern: roving focus, arrows, typeahead. |
282
+ | `menubarKeys(options?)` | `Menubar` | The ARIA menubar pattern, handing off into each open `Menu`. |
283
+ | `messageFollow(model)` | `MessageScroller.Viewport` | Follows new turns through a `ScrollFollowModel`. |
284
+ | `mirrorSelectedOption()` | a `<selectedcontent>` | Keeps the customizable select's trigger showing the chosen option. |
285
+ | `otpSlots()` | an `OtpField` group | Focus moving across slots, and pasted codes split. |
286
+ | `persist(key)` | `Sidebar` | The collapsed state saved to a cookie, plus a `--ui-toggle` command. |
287
+ | `pressToggle()` | `ToggleButton` | Flips `aria-pressed` on click. |
288
+ | `rangePreview(model)` | `RangeCalendar.Grid` | Hover and focus preview of the pending range. |
289
+ | `resizeHandle(axis, session)` | `Resizable.Handle` | Pointer resizing through a `ResizeSession`. |
290
+ | `stepper(options?)` | `NumberField.Group` | Press-and-hold repeat on the step buttons. |
291
+ | `tabKeys(options?)` | `Tabs.List` | Arrow, Home/End tab activation. |
292
+ | `themeToggle(options?)` | any host | `--ui-theme-light`/`-dark`/`-system` commands saved to a cookie. |
293
+ | `treeKeys(model)` | `Tree` | The ARIA tree pattern over a `SelectionModel`. |
294
+ | `validate(schema)` | a form control | A `remix/data-schema` check through `setCustomValidity()`. |
295
+ | `viewTransition()` | a `SharedElement` island | A View Transition across a same-document reload. |
296
+
297
+ Helpers for writing your own:
298
+
299
+ - `whileLive(handle, subscribe)` — returns a function that subscribes to a model, session or frame
300
+ only while the mixin or island is live in a document, aborting on unmount.
301
+ - `trackHostNode(handle)` — returns a getter for the mixin's current host node.
302
+ - `bindKeymap(document, bindings, { signal, scope? })` — `keymap` without a host, with the same
303
+ stand-down rules as `isClaimedKeystroke(event, scope?)`.
304
+ - `syncAriaChecked(control)` — refreshes `ariaChecked` after a programmatic checked write or reset.
305
+ - `colorChannelProperty(channel)` and `getCommandItemId(item, index)` — the custom property and the
306
+ item id `channelSync` and `commandFilter` read.
307
+
308
+ Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `ReorderEvent`,
309
+ `ThemeChangeEvent`, …), and those that read markup export the `data-*` attribute and command names
310
+ they use (`DRAG_REORDER_ROW_ATTRIBUTE`, `SEARCH_FIELD_CLEAR_COMMAND`, …).
311
+
312
+ ### Behavior classes
313
+
314
+ DOM-free state that dispatches `change`; an island subscribes and re-renders.
315
+
316
+ - `Announcer({ hold? })` — an `aria-live` queue: `announce(text, priority?)`, `current`, `next()`.
317
+ - `CalendarModel({ focusedDate?, min?, max?, isDateDisabled? })` — the focused day, visible month,
318
+ and an in-progress range (`beginRange`, `completeRange`).
319
+ - `DragSession<Data>()` — the dragged `source`, the `target` under the pointer with its
320
+ `"before" | "after" | "on"` position, and `drop()`.
321
+ - `FilterModel({ options?, query?, match? })` — query, `matches`, and the active match.
322
+ - `ResizeSession()` — panel sizes during a resize, cascading into neighbors at their limits.
323
+ - `ScrollFollowModel({ pinned? })` — whether the log follows the live edge, visible messages, and
324
+ pending scroll requests.
325
+ - `SelectionModel({ mode?, keys?, selectedKeys? })` — `toggle`, `selectRange`, `selectAll` over a
326
+ key set.
327
+ - `Toaster<Data>({ defaultDuration? })` — `add(data, options?)`, `toasts`, `dismiss(id)`,
328
+ `pause`/`resume`, with each toast's timer owned by the queue.
385
329
 
386
330
  ### Animations
387
331
 
388
- CSS-only `css()` factories keyed off native open states, all sharing `easings` (`standard`,
389
- `decelerate`, `accelerate`, `linear`) and `durations` (`fast` 150ms, `normal` 200ms, `slow`
390
- 300ms, `slower` 400ms).
391
-
392
- - `enterExit(options?)` — the composer: exit declarations on the host, entered state under
393
- `[open]`/`:popover-open` or a selector you name, a `@starting-style` block, and a
394
- reduced-motion override.
395
- - `fade(options?)`, `zoom(options?)`, `slide(options)` — sugar over `enterExit` for a plain
396
- fade, a fade with a scale, and a fade with a directional offset.
397
- - `spin(options?)`, `pulse(options?)` — continuous rotation for a busy glyph, and a gentle
398
- opacity breathe for a placeholder.
399
- - `shimmer(options?)`, `textShimmer(options?)` — a sweeping highlight across a progress
400
- fill, and the same sweep through text via `background-clip: text`.
401
- - `scrollShadow(options?)`, `scrollProgress(options?)`, `scrollFade(options?)` — a sticky
402
- header's shadow, a fill that grows with scroll distance, and faded scroll-container edges,
403
- all on `animation-timeline: scroll()`.
404
- - `viewReveal(options?)` — an entry motion played as an element scrolls into view, on a
405
- `view()` timeline.
406
-
407
- ### Style Mixins
408
-
409
- Recipes composed directly in a `mix` array.
410
-
411
- - `floatingSurface()`, `panelChrome()`, `semanticColorPanel()` — the border, rounding, tint
412
- and elevation a floating surface carries; the border and rounding a framed panel applies;
413
- and the `&[data-color="…"]` branches a tinted panel keys its colors on.
414
- - `interactiveTransition()` — the shared transition property, timing and duration for a
415
- control's hover, focus, press and validity changes.
416
- - `fieldStackLayout()`, `outputCaptionText()` — the single-column stacking every field
417
- wrapper's host uses, and the muted caption typography every `<output>` shares.
418
- - `graphicHostStyle()` — the flex-item layout and `currentColor` declarations a leading icon
419
- or loading graphic shares, so the two swap without shifting layout.
420
- - `rangeThumbAppearance(sizeVar, borderWidthVar)` — the circular range thumb: appearance
421
- reset, fill and border, elevation, pressed scale, focus ring, disabled dimming.
422
- - `rtlAwareGradientDirection(propertyName)` — a custom-property pairing behind a gradient
423
- direction, flipped under `&:dir(rtl)`.
424
- - `chartPalette(property, combinator?)`, `legendToggle()` — paints one property from
425
- whichever of the `CHART_COLOR_SLOT_COUNT` `--ui-chart-*` slots an element's `data-color`
426
- names, and the position-keyed rules pairing a chart root with a later-sibling legend.
332
+ CSS-only factories keyed off `[open]`/`:popover-open` (or a `when` selector), each collapsing to an
333
+ opacity fade under reduced motion.
334
+
335
+ - `enterExit(options?)` — the composer behind the rest; `exit` sets quieter leaving values.
336
+ - `fade(options?)`, `zoom(options?)`, `slide({ from, ... })` — a fade, a fade with scale, and a fade
337
+ with an offset from `"top" | "right" | "bottom" | "left"`.
338
+ - `spin()`, `pulse()`, `shimmer()`, `textShimmer()` — continuous motion for busy and loading states.
339
+ - `scrollShadow()`, `scrollProgress()`, `scrollFade()`, `viewReveal()` — scroll- and view-timeline
340
+ effects.
341
+ - `durations` — `fast` 150, `normal` 200, `slow` 300, `slower` 400 (ms); `easings` — `standard`,
342
+ `decelerate`, `accelerate`, `linear`.
343
+
344
+ ### Styles
345
+
346
+ Recipes for a `mix` array: `floatingSurface()`, `surfaceInset()`, `hitArea()`, `panelChrome()`,
347
+ `semanticColorPanel()`, `interactiveTransition()`, `fieldStackLayout()`, `outputCaptionText()`,
348
+ `graphicHostStyle()`, `rangeThumbAppearance(sizeVar, borderWidthVar)`,
349
+ `rtlAwareGradientDirection(propertyName)`, `chartPalette(property, combinator?)` (one of
350
+ `CHART_COLOR_SLOT_COUNT` chart colors from `data-color`) and `legendToggle()`.
427
351
 
428
352
  ### Utilities
429
353
 
430
- Plain TypeScript with no rendering dependency, importable on its own.
431
-
432
- - **Color** — `parseColor`, `formatHex`/`formatRgb`/`formatHsl`, `rgbToHsl`/`hslToRgb`,
433
- `rgbToHsv`/`hsvToRgb`, `clampChannel`, `roundChannel`, and the `HSLColor`, `HSVColor`,
434
- `RGBColor`, `RGBAColor` interfaces.
435
- - **Charts** — `linearScale`, `bandScale`, `ticks`, `linePath`, `areaPath`, `arcPath`,
436
- `pieAngles`, `computeMarkerIndices`, `HUE_GRADIENT_STOPS`.
437
- - **Geometry** — `normalizedPointerPosition`, `angleFromCenter`, `angleToHue`/`hueToAngle`,
438
- `resolveFillPercent`, `FULL_TURN_RADIANS`, and the `Point`/`Rect` interfaces.
439
- - **Fields** — `resolveFieldWiring` and `findPairedRangeInputs`, plus the `FieldWiring`,
440
- `FieldWiringOptions` and `FieldPartsProps` shapes behind every wrapper's `parts` prop.
441
- - **DOM** — `asCommandEvent`, `dispatchChange`, `isNewPrimaryPress`, `isPrintableKey`,
442
- `focusItem`, `queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`,
443
- `mergeStyle`, `prefersReducedMotion`, `writeCookie`, `DISABLED_SELECTOR`.
444
- - **Keys** — `parseKeyCombo`, `matchesKeyCombo`, `keyComboGlyphs`, `isTypingTarget`,
445
- `TYPING_TARGET_SELECTOR`, and the `KeyCombo` interface. A combo is written once
446
- (`"mod+k"`, `"escape"`, `"?"`) and both matched and printed from that spelling: `mod` is
447
- Command on Apple keyboards and Control elsewhere, and a bare character names the character
448
- typed, so `"J"` and `"?"` match whatever Shift produced them.
449
- - **Types** — `SemanticColor` (the five-tone union every `color` prop resolves to),
450
- `AnchorPlacement`, `AriaInvalid`, `CSSStyles`, `StyleProp`, `FieldColor`.
451
-
452
- ## Pattern: A Behavior Class Behind A Hydrated Widget
453
-
454
- State with real shape — a toast queue, a selection set — lives in a behavior class, not in
455
- the component and not in the mixin. The island owns the instance and re-renders on its
456
- events:
354
+ - **Color** — `parseColor(input): RGBAColor | null`, `formatHex`, `formatRgb`, `formatHsl`,
355
+ `rgbToHsl`, `hslToRgb`, `rgbToHsv`, `hsvToRgb`, `clampChannel`, `roundChannel`.
356
+ - **Charts** — `linearScale(domain, range)`, `bandScale(domain, range)`, `ticks(domain, count)`,
357
+ `linePath`, `areaPath`, `arcPath`, `pieAngles`, `computeMarkerIndices`, `HUE_GRADIENT_STOPS`.
358
+ - **Geometry** — `normalizedPointerPosition`, `angleFromCenter`, `angleToHue`, `hueToAngle`,
359
+ `resolveFillPercent`, `FULL_TURN_RADIANS`.
360
+ - **Keys** — `parseKeyCombo`, `matchesKeyCombo(event, combo)`, `keyComboGlyphs(combo, apple)`,
361
+ `isTypingTarget`, `TYPING_TARGET_SELECTOR`. A combo is spelled once (`"mod+k"`, `"escape"`,
362
+ `"?"`); `mod` is Command on Apple keyboards and Control elsewhere.
363
+ - **Fields** — `resolveFieldWiring(id, options)`, `findPairedRangeInputs`.
364
+ - **DOM** — `asCommandEvent`, `dispatchChange`, `isNewPrimaryPress`, `isPrintableKey`, `focusItem`,
365
+ `queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`, `mergeStyle`, `prefersReducedMotion`, `writeCookie(name, value, maxAgeSeconds?)`,
366
+ `DISABLED_SELECTOR`, `DEFAULT_ICON_ARIA_HIDDEN`, `ONE_YEAR_SECONDS`.
367
+ - **Accessibility checks** — `warnIfNoAccessibleName(props, children, message)` and
368
+ `warnIfNoAccessibleLabel(props, message)`, development-only warnings.
369
+ - **Panels** — `semanticColorPanelStyle(color)`, the border, background and text declarations for
370
+ one semantic color.
371
+
372
+ ### Types
373
+
374
+ `SemanticColor`, `FieldColor`, `AnchorPlacement`, `AriaInvalid`, `AriaInvalidToken`, `CSSStyles`,
375
+ `StyleProp`, `StyleDeclarations`, `HeadingLevel`, `FieldIssueState`, `FieldWiring`,
376
+ `FieldWiringOptions`, `FieldPartsProps`, `AccessibleNameProps`, `SemanticColorPanelStyle`,
377
+ `KeyCombo`, `Point`, `Rect`, `RGBColor`, `RGBAColor`, `HSLColor`, `HSVColor`, and the option
378
+ namespaces `LinearScale`, `BandScale`, `ArcPath` and `PieAngles` from `./utils`. Each component,
379
+ mixin, behavior and animation also exposes its option types on its own namespace (`Toaster.Init`,
380
+ `Dismiss.Options`, `Fade.Options`).
381
+
382
+ ## Pattern: A Validated Form
383
+
384
+ `Form` hands a failed parse's issues to each field by `name`; the field renders its `FieldError`,
385
+ sets `aria-invalid`, and the first invalid one takes focus. Native constraints still block bad
386
+ input before any JavaScript runs.
387
+
388
+ ```tsx
389
+ import type { Handle } from "remix/component";
390
+
391
+ import * as s from "remix/data-schema";
392
+ import * as checks from "remix/data-schema/checks";
393
+ import * as f from "remix/data-schema/form-data";
394
+
395
+ import { Button, Form, TextField } from "@sdxc/ui";
396
+
397
+ export let ContactSchema = f.object({
398
+ email: f.field(s.string().pipe(checks.minLength(1), checks.email())),
399
+ });
400
+
401
+ export function ContactPage(handle: Handle<{ issues?: ReadonlyArray<Form.Issue> }>) {
402
+ return () => (
403
+ <Form method="post" issues={handle.props.issues}>
404
+ <TextField label="Email" name="email" type="email" required />
405
+ <Button type="submit">Send</Button>
406
+ </Form>
407
+ );
408
+ }
409
+
410
+ // In the POST handler:
411
+ // let result = s.parseSafe(ContactSchema, formData);
412
+ // if (!result.success) render <ContactPage issues={result.issues} /> with status 400
413
+ ```
414
+
415
+ Pass `errorMessage` to a field for a message the schema does not produce, or apply
416
+ `validate(schema)` from `@sdxc/ui/mixins` to check a control in the browser as the user types.
417
+
418
+ ## Pattern: A Confirmed Destructive Action
419
+
420
+ `Confirm` with `form` wraps its buttons in a real `<form>`, so confirming is an ordinary POST and
421
+ cancelling only closes the dialog:
422
+
423
+ ```tsx
424
+ import { Button, Confirm } from "@sdxc/ui";
425
+
426
+ <Button commandfor="revoke-session" command="show-modal" color="danger">
427
+ Revoke session
428
+ </Button>
429
+ <Confirm
430
+ id="revoke-session"
431
+ title="Revoke this session?"
432
+ description="The device is signed out immediately."
433
+ confirmLabel="Revoke"
434
+ cancelLabel="Cancel"
435
+ color="danger"
436
+ form={{
437
+ action: "/sessions/revoke",
438
+ method: "post",
439
+ fields: <input type="hidden" name="sessionId" value="42" />,
440
+ }}
441
+ />;
442
+ ```
443
+
444
+ Render it outside any other `<form>`. Without `form`, the confirm button closes the dialog and your
445
+ page decides what confirmation means; for anything else, compose `AlertDialog` and its parts.
446
+
447
+ ## Pattern: A Toast Queue
448
+
449
+ A `Toaster` owns the queue and each toast's timer; an island subscribes with `whileLive` and
450
+ publishes the queue through context so any descendant can add to it:
457
451
 
458
452
  ```tsx
459
453
  import type { Handle } from "remix/component";
@@ -464,79 +458,113 @@ import { Toast } from "@sdxc/ui";
464
458
  import { Toaster } from "@sdxc/ui/behaviors";
465
459
  import { whileLive } from "@sdxc/ui/mixins";
466
460
 
467
- export const AppToaster = clientEntry(
468
- "/app/components/app-toaster.tsx#AppToaster",
469
- function AppToaster(handle: Handle) {
470
- let toaster = new Toaster<{ title: string; color?: Toast.Color }>();
461
+ export let Toasts = clientEntry("/components/toasts.tsx#Toasts", function Toasts(handle: Handle) {
462
+ let toaster = new Toaster<{ title: string; color?: Toast.Color }>({ defaultDuration: 5000 });
471
463
 
472
- whileLive(handle, (model: Toaster, signal) =>
473
- model.addEventListener("change", () => handle.update(), { signal }),
474
- )(toaster);
475
- handle.context.set({ toaster });
464
+ whileLive(handle, (model: Toaster, signal) =>
465
+ model.addEventListener("change", () => handle.update(), { signal }),
466
+ )(toaster);
467
+ handle.context.set({ toaster });
476
468
 
477
- return () => (
478
- <Toast.Region aria-label={t("toasts.region")}>
479
- {toaster.toasts.map((toast) => (
480
- <Toast key={toast.id} color={toast.data.color}>
481
- <Toast.Content>
482
- <Toast.Title>{toast.data.title}</Toast.Title>
483
- </Toast.Content>
484
- </Toast>
485
- ))}
486
- </Toast.Region>
487
- );
488
- },
489
- );
469
+ return () => (
470
+ <Toast.Region aria-label="Notifications" placement="bottom-end">
471
+ {toaster.toasts.map((toast) => (
472
+ <Toast key={toast.id} color={toast.data.color}>
473
+ <Toast.Content>
474
+ <Toast.Title>{toast.data.title}</Toast.Title>
475
+ </Toast.Content>
476
+ </Toast>
477
+ ))}
478
+ </Toast.Region>
479
+ );
480
+ });
481
+
482
+ // Anywhere below it:
483
+ // handle.context.get(Toasts).toaster.add({ title: "Saved", color: "success" });
490
484
  ```
491
485
 
492
- Any descendant reaches the queue through context:
493
- `handle.context.get(AppToaster).toaster.add({ title: t("toasts.saved") })`.
486
+ ## Pattern: Custom Commands From Static Buttons
487
+
488
+ A `command` starting with `--` reaches its `commandfor` target as a `CommandEvent` with no built-in
489
+ behavior, and mixins answer the `--ui-*` ones. The buttons stay server markup anywhere on the page,
490
+ outside the island that owns the target; parameters ride the button's `data-*` attributes:
494
491
 
495
- ## Pattern: A Keyboard Shortcuts Panel
492
+ ```tsx
493
+ import { Button, Carousel } from "@sdxc/ui";
494
+ import { carouselControls, themeToggle } from "@sdxc/ui/mixins";
495
+
496
+ <Carousel aria-label="Product photos">
497
+ <Carousel.Viewport id="photos" mix={carouselControls()}>
498
+ <Carousel.Track>
499
+ <Carousel.Slide>
500
+ <img src="/front.jpg" alt="Front" />
501
+ </Carousel.Slide>
502
+ <Carousel.Slide>
503
+ <img src="/back.jpg" alt="Back" />
504
+ </Carousel.Slide>
505
+ </Carousel.Track>
506
+ </Carousel.Viewport>
507
+ <Carousel.Controls>
508
+ <Carousel.Previous commandfor="photos" aria-label="Previous photo" />
509
+ <Carousel.Next commandfor="photos" aria-label="Next photo" />
510
+ </Carousel.Controls>
511
+ </Carousel>
512
+ <Button commandfor="photos" command="--ui-goto" data-slide="1">
513
+ Show back
514
+ </Button>
515
+
516
+ <div id="theme" mix={themeToggle()}>
517
+ <Button commandfor="theme" command="--ui-theme-light">Light</Button>
518
+ <Button commandfor="theme" command="--ui-theme-dark">Dark</Button>
519
+ <Button commandfor="theme" command="--ui-theme-system">System</Button>
520
+ </div>;
521
+ ```
496
522
 
497
- The bindings, the panel that lists them, and the live region that says what a key did are
498
- three independent pieces. `keymap()` binds the keys on the island's host, so a panel rendered
499
- inside that host keeps answering them while any other dialog keeps its own keys; the panel
500
- is a native `<dialog>` the `?` key opens through the same button a pointer presses; and an
501
- `Announcer` with a `hold` paces what the live region reads.
523
+ `themeToggle` sets `.dark` or `.system` on `<html>` and writes the `ui:theme` cookie, so your server
524
+ can render the same class on the next request. `Button` and the invoker parts render
525
+ `type="button"` when they carry `command`; a hand-written `<button commandfor>` inside a `<form>`
526
+ needs `type="button"` before its `command` attributes, or the platform runs nothing.
527
+
528
+ ## Pattern: Keyboard Shortcuts
529
+
530
+ `keymap` binds shortcuts on an island's host, a `Modal` lists them with `ShortcutList`, and an
531
+ `Announcer` paces what a live region reads:
502
532
 
503
533
  ```tsx
504
534
  import type { Handle } from "remix/component";
505
535
 
506
- import { visuallyHidden } from "@sdxc/u/a11y";
536
+ import { clientEntry } from "remix/component";
537
+
507
538
  import { Button, Modal, ShortcutList } from "@sdxc/ui";
508
539
  import { Announcer } from "@sdxc/ui/behaviors";
509
540
  import { keymap, whileLive } from "@sdxc/ui/mixins";
510
541
  import { keyComboGlyphs } from "@sdxc/ui/utils";
511
- import { clientEntry } from "remix/component";
512
-
513
- type Props = { apple: boolean };
514
542
 
515
543
  export default clientEntry(
516
- "/app/components/shortcuts.tsx#default",
517
- function Shortcuts(handle: Handle<Props>) {
544
+ "/components/shortcuts.tsx#default",
545
+ function Shortcuts(handle: Handle<{ apple: boolean }>) {
518
546
  let announcer = new Announcer({ hold: 1200 });
519
547
  whileLive(handle, (model: Announcer, signal) =>
520
548
  model.addEventListener("change", () => handle.update(), { signal }),
521
549
  )(announcer);
522
550
 
523
- let openHelp = () =>
524
- document.querySelector<HTMLButtonElement>('[commandfor="shortcuts"]')?.click();
551
+ let save = () => announcer.announce("Saved");
552
+ let openHelp = () => document.querySelector<HTMLDialogElement>("#shortcuts")?.showModal();
525
553
 
526
554
  return () => (
527
- <div mix={[keymap({ "mod+s": save, j: next, "?": openHelp })]}>
528
- <Button type="button" commandfor="shortcuts" command="show-modal">
529
- {t("shortcuts.open")}
555
+ <div mix={keymap({ "mod+s": save, "?": openHelp })}>
556
+ <Button commandfor="shortcuts" command="show-modal">
557
+ Keyboard shortcuts
530
558
  </Button>
531
- <Modal id="shortcuts" aria-label={t("shortcuts.open")}>
559
+ <Modal id="shortcuts" aria-label="Keyboard shortcuts">
532
560
  <ShortcutList>
533
561
  <ShortcutList.Item keys={keyComboGlyphs("mod+s", handle.props.apple)}>
534
- {t("shortcuts.save")}
562
+ Save
535
563
  </ShortcutList.Item>
536
- <ShortcutList.Item keys={["j"]}>{t("shortcuts.next")}</ShortcutList.Item>
564
+ <ShortcutList.Item keys={["?"]}>Show shortcuts</ShortcutList.Item>
537
565
  </ShortcutList>
538
566
  </Modal>
539
- <div role="status" aria-live="polite" mix={[visuallyHidden()]}>
567
+ <div role="status" aria-live="polite">
540
568
  {announcer.current?.text ?? ""}
541
569
  </div>
542
570
  </div>
@@ -545,312 +573,140 @@ export default clientEntry(
545
573
  );
546
574
  ```
547
575
 
548
- Where the bindings are installed from a `ref` callback instead of a mixin, `bindKeymap(document,
549
- bindings, { signal, scope })` takes the same map and the same stand-down rules.
550
-
551
- ## Pattern: The Custom Command Trigger Contract
552
-
553
- [Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
554
- go beyond the built-in `show-modal`, `close` and `toggle-popover` values: any `command`
555
- prefixed with `--` dispatches a `CommandEvent` on its `commandfor` target with no built-in
556
- behavior. That is the trigger contract between static server buttons and hydrated widgets.
557
-
558
- A widget-root mixin listens for `command` on its host and switches on `event.command`.
559
- Library commands carry the `--ui-` prefix (`--ui-next`, `--ui-dismiss`, `--ui-toggle`), and
560
- unknown commands pass through, so an app's own `--` commands can target the same elements.
561
- Trigger buttons stay static markup anywhere on the page, including outside the island that
562
- owns the widget. Parameters ride the invoker — `event.source` is the triggering button, so
563
- this carries its payload in `event.source.dataset`:
564
-
565
- ```tsx
566
- <button commandfor="cart-carousel" command="--ui-goto" data-slide="3">
567
- {t("carousel.goto", { slide: 3 })}
568
- </button>
569
- ```
570
-
571
- `Button` renders `type="button"` on its own whenever it carries `command` or `commandfor`,
572
- as do `Dialog.Close`, `AlertDialog.Cancel` and the other invoker parts. A button inside a
573
- `<form>` otherwise defaults to `"submit"`, and the platform then treats the pairing as
574
- ambiguous and runs nothing. A hand-rolled `<button commandfor=…>` inside a form spells
575
- `type="button"` out, written ahead of `command`/`commandfor`, since the platform judges the
576
- pairing as it parses those attributes.
577
-
578
- ## Pattern: The Ambient Heading Scope
579
-
580
- `HeadingScope` publishes a heading depth through `handle.context`, one level deeper than the
581
- `HeadingScope` it is nested inside, or `1` where nothing wraps it. `Heading` — and every
582
- title slot, such as `Dialog.Title`, `Alert.Title` and `Empty.Title` — reads that depth:
583
-
584
- ```tsx
585
- <HeadingScope>
586
- <Heading>{t("doc.title")}</Heading> {/* <h1>, no ancestor scope */}
587
- <HeadingScope>
588
- <Heading>{t("doc.section")}</Heading> {/* <h2>, one level deeper */}
589
- </HeadingScope>
590
- </HeadingScope>
591
- ```
592
-
593
- An independently hydrated island has no ancestor context to read, even where the
594
- server-rendered page nests it under a real scope. Threading the level down as an explicit
595
- `level` prop is the first choice. Where that is impractical, apply
596
- `headingLevelFallback({ onLevel })` to the island's own `HeadingScope`: it reads the
597
- `data-heading-level` attribute `HeadingScope` and `Heading` already stamp on the DOM, hands
598
- the detected `HeadingLevel` to the callback once on attach, and the island stores it and
599
- re-renders with `level` set.
576
+ Bindings stand down while the user types in a field, composes with an IME, or works in a dialog
577
+ outside the host. `hotkey("mod+k")` on a `<dialog>` or popover is the one-shortcut shorthand.
600
578
 
601
- ## Pattern: Composing Recipes In One `mix` Array
579
+ ## Pattern: Restyling A Component
602
580
 
603
- A style recipe, an animation factory, and a local `css()` call compose as disjoint siblings
604
- in one array:
581
+ `mix` adds declarations to a component's host, `parts` reaches the inner elements of a wrapper, and
582
+ the style recipes and animation factories compose with your own `css()` in one array:
605
583
 
606
584
  ```tsx
607
585
  import { css } from "remix/component";
608
586
 
587
+ import { Card, TextField } from "@sdxc/ui";
609
588
  import { zoom } from "@sdxc/ui/animations";
610
- import { floatingSurface, interactiveTransition } from "@sdxc/ui/styles";
589
+ import { floatingSurface } from "@sdxc/ui/styles";
590
+
591
+ <Card mix={css({ maxInlineSize: "32rem" })} style={{ "--ui-radius-lg": "1rem" }}>
592
+ <TextField
593
+ label="Username"
594
+ name="username"
595
+ parts={{ input: css({ fontFamily: "var(--ui-font-mono)" }) }}
596
+ />
597
+ </Card>
611
598
 
612
599
  <div
613
600
  id="account-menu"
614
601
  popover="auto"
615
- mix={[
616
- floatingSurface(),
617
- interactiveTransition(),
618
- zoom({ scale: 0.95, duration: 150 }),
619
- css({ margin: "0", inset: "auto", paddingBlock: "0.5rem" }),
620
- ]}
602
+ mix={[floatingSurface(), zoom({ scale: 0.95 }), css({ paddingBlock: "0.5rem" })]}
621
603
  >
622
- {menuItems}
604
+ Signed in as Ada
623
605
  </div>;
624
606
  ```
625
607
 
626
- `floatingSurface()` supplies the chrome, `interactiveTransition()` the shared transition
627
- triplet for descendants, and `zoom()` the open and close motion off the popover's own
628
- `:popover-open` state.
629
-
630
- Each entry compiles to one hashed class in its own cascade sublayer, and a class's layer
631
- position is fixed the first time that exact declaration set appears on the page — so `mix`
632
- is where declarations the component does not already set belong. To settle a declaration the
633
- component already makes, four routes win outright: the `style` prop, an inline override of
634
- the component's own token (`style={{ "--ui-text-2xl": "0.875rem" }}`), a `raw()` declaration
635
- marked `!important`, or a rule in an app cascade layer declared after `rmx`.
636
-
637
- ## Pattern: Styling One Part Of A Wrapper
638
-
639
- A wrapper rendering more than one host element takes a `parts` prop, one `mix` per named
640
- part. `TextField`'s four — `label`, `input`, `description`, `error` — are the base shape
641
- every field wrapper extends:
642
-
643
- ```tsx
644
- import { css } from "remix/component";
645
-
646
- import { TextField } from "@sdxc/ui";
647
-
648
- <TextField
649
- label={t("form.username.label")}
650
- name="username"
651
- parts={{ input: css({ fontFamily: "var(--ui-font-mono)" }) }}
652
- />;
653
- ```
654
-
655
- `ColorField` adds `control` (the row wrapping input and swatch) and `swatch` to that base.
656
- `Confirm` exposes parts matching each of its composed pieces — `header`, `title`,
657
- `description`, `footer`, `cancel`, `action`, and `form` in submit mode. Where `parts` runs
658
- out, composing the underlying components directly — `Label` plus `Input` plus `Description`
659
- plus `FieldError`, or `AlertDialog` and its own parts — covers the rest.
660
-
661
- ## Pattern: A Confirmed Destructive Action
662
-
663
- Given a `form` prop, `Confirm` wraps its content in a real `<form>` and the confirming
664
- control becomes that form's submit button, so a destructive action runs as an ordinary form
665
- post with no client JavaScript. `fields` renders the hidden inputs the submission needs:
666
-
667
- ```tsx
668
- import { Button, Confirm } from "@sdxc/ui";
669
-
670
- <Button commandfor="revoke-session" command="show-modal" color="danger">
671
- {t("session.revoke")}
672
- </Button>
673
- <Confirm
674
- id="revoke-session"
675
- title={t("session.revokeTitle")}
676
- confirmLabel={t("actions.revoke")}
677
- cancelLabel={t("actions.cancel")}
678
- form={{
679
- action: revokeUrl,
680
- fields: <input type="hidden" name="intent" value="revoke" />,
681
- }}
682
- />;
683
- ```
684
-
685
- Without `form`, the confirming control closes the panel and the page decides what a
686
- confirmed decision means. The cancel control stays a close-command button in both modes, so
687
- cancelling never submits. Submit mode renders a `<form>`, so the panel belongs outside any
688
- other form's markup, per the platform's own nesting rule. For a shape this does not cover,
689
- compose `AlertDialog` directly and give `AlertDialog.Action` a `type="submit"`: it then
690
- submits the enclosing form instead of running a command.
608
+ To change a declaration the component already sets, override its `--ui-*` variable (as above), use
609
+ `style`, or write the rule in a cascade layer declared after `rmx`. When `parts` is not enough,
610
+ compose the underlying pieces (`Label`, `Input`, `Description`, `FieldError`) directly.
691
611
 
692
- ## Pattern: A Validated Form
612
+ ## Pattern: A Chart With A Legend
693
613
 
694
- `Form` takes a parsed validation result and hands each field its own errors by name through
695
- context. The canonical shape is an action that parses the submission and re-renders the same
696
- page with `issues` set:
614
+ Charts render as accessible SVG on the server: every point is a focusable marker whose `label` is its
615
+ native tooltip. A `Chart.Legend` placed after the chart pairs its items with the series by order:
697
616
 
698
617
  ```tsx
699
618
  import type { Handle } from "remix/component";
700
619
 
701
- import * as s from "remix/data-schema";
702
- import { parseSafe } from "remix/data-schema";
703
- import * as checks from "remix/data-schema/checks";
704
- import * as f from "remix/data-schema/form-data";
620
+ import { css } from "remix/component";
705
621
 
706
- import { Button, Form, TextField } from "@sdxc/ui";
622
+ import { Chart } from "@sdxc/ui";
707
623
 
708
- let ContactSchema = f.object({
709
- email: f.field(s.string().pipe(checks.minLength(1), checks.email())),
710
- });
624
+ interface Point {
625
+ x: number;
626
+ y: number;
627
+ label: string;
628
+ }
711
629
 
712
- function ContactPage(handle: Handle<{ issues?: ReadonlyArray<Form.Issue> }>) {
630
+ export function RevenueChart(handle: Handle<{ revenue: Point[]; refunds: Point[] }>) {
713
631
  return () => (
714
- <Form method="post" issues={handle.props.issues}>
715
- <TextField label={t("contact.email.label")} name="email" type="email" required />
716
- <Button type="submit">{t("contact.submit")}</Button>
717
- </Form>
632
+ <>
633
+ <Chart
634
+ width={480}
635
+ height={240}
636
+ xDomain={[0, 11]}
637
+ yDomain={[0, 5000]}
638
+ aria-label="Revenue by month"
639
+ >
640
+ <Chart.Line color={1} points={handle.props.revenue} />
641
+ <Chart.Line
642
+ color={3}
643
+ points={handle.props.refunds}
644
+ parts={{ path: css({ strokeDasharray: "4 4" }) }}
645
+ />
646
+ </Chart>
647
+ <Chart.Legend aria-label="Series">
648
+ <Chart.Legend.Item color={1}>Revenue</Chart.Legend.Item>
649
+ <Chart.Legend.Item color={3}>Refunds</Chart.Legend.Item>
650
+ </Chart.Legend>
651
+ </>
718
652
  );
719
653
  }
720
-
721
- // In the handler for the POST:
722
- let result = parseSafe(ContactSchema, formData);
723
- if (!result.success) return render(<ContactPage issues={result.issues} />, { status: 400 });
724
654
  ```
725
655
 
726
- The native constraint attributes (`required`, `type="email"`) block submission with no
727
- JavaScript at all, and a failed parse re-renders the same page with its issues carried
728
- through a plain prop.
656
+ `color` picks one of the eight `--ui-chart-*` colors. `Chart.Area` plots inside a `Chart` the same
657
+ way; `Chart.Bar` and `Chart.Pie` are standalone SVGs sized by their own `width` and `height`.
729
658
 
730
- `issues` is the only thing the page passes: `TextField`, `DateField`, `TimeField` and
731
- `ColorField` each look their own message up by `name` through form context. A field found in
732
- `issues` renders its `FieldError`, marks `aria-invalid`, wires `aria-describedby` at the
733
- message, and — for the first invalid field of the render — picks up `autofocus`. An explicit
734
- `errorMessage` or `autoFocus` decides that field instead, for a message the schema does not
735
- produce.
659
+ ## Pattern: A Message Thread That Follows New Turns
736
660
 
737
- ## Pattern: A Chart With A Legend
738
-
739
- `Chart.Legend` renders as a later sibling of the chart root, and each `Chart.Legend.Item`
740
- appears in the same order as its matching series: the toggle wiring keys off sibling
741
- position rather than a series id.
661
+ `messageFollow` keeps the log pinned to the newest turn until the reader scrolls away, then reveals
662
+ the jump-to-latest button:
742
663
 
743
664
  ```tsx
744
- import { css } from "remix/component";
745
-
746
- import { Chart } from "@sdxc/ui";
747
-
748
- <>
749
- <Chart
750
- width={480}
751
- height={240}
752
- xDomain={[0, 11]}
753
- yDomain={[0, 5000]}
754
- aria-label={t("chart.label")}
755
- >
756
- <Chart.Line color={1} points={revenuePoints} />
757
- <Chart.Line color={3} points={refundPoints} parts={{ path: css({ strokeDasharray: "4 4" }) }} />
758
- </Chart>
759
- <Chart.Legend aria-label={t("chart.legend")}>
760
- <Chart.Legend.Item color={1}>{t("chart.series.revenue")}</Chart.Legend.Item>
761
- <Chart.Legend.Item color={3}>{t("chart.series.refunds")}</Chart.Legend.Item>
762
- </Chart.Legend>
763
- </>;
764
- ```
765
-
766
- Each point carries `x`, `y` and a `label` that becomes its native `<title>`, and every wedge,
767
- bar and marker stays keyboard-reachable on its own — this chart needs no `clientEntry` at
768
- all. `chartTooltip()` is the separate, opt-in mixin for a floating tooltip synced to the
769
- nearest point under the pointer or focus.
770
-
771
- ## Pattern: A Message Thread
772
-
773
- `MessageScroller`, `Message`, `Bubble` and `Marker` compose into a conversational thread, and
774
- `messageFollow()` bridges the viewport to a `ScrollFollowModel` so the log follows new turns
775
- until a person scrolls away from the live edge:
665
+ import type { Handle } from "remix/component";
776
666
 
777
- ```tsx
778
- import { css } from "remix/component";
667
+ import { clientEntry, css } from "remix/component";
779
668
 
780
669
  import { Bubble, Message, MessageScroller } from "@sdxc/ui";
781
670
  import { ScrollFollowModel } from "@sdxc/ui/behaviors";
782
671
  import { messageFollow } from "@sdxc/ui/mixins";
783
672
 
784
- let model = new ScrollFollowModel({ pinned: true });
785
-
786
- <MessageScroller mix={css({ blockSize: "32rem" })}>
787
- <MessageScroller.Viewport mix={messageFollow(model)}>
788
- <MessageScroller.Content>
789
- {turns.map((turn, index) => (
790
- <MessageScroller.Item key={turn.id} messageId={turn.id} scrollAnchor={index === 0}>
791
- <Message>
792
- <Message.Content>
793
- <Bubble align={turn.isSelf ? "end" : "start"} variant="muted">
794
- <Bubble.Content>{turn.text}</Bubble.Content>
795
- </Bubble>
796
- </Message.Content>
797
- </Message>
798
- </MessageScroller.Item>
799
- ))}
800
- </MessageScroller.Content>
801
- </MessageScroller.Viewport>
802
- <MessageScroller.Button aria-label={t("chat.jumpToLatest")}>
803
- {t("chat.jumpToLatest")}
804
- </MessageScroller.Button>
805
- </MessageScroller>;
806
- ```
807
-
808
- `MessageScroller.Item`'s `messageId` is required and unique per turn.
809
- `MessageScroller.Button` starts `hidden` and is revealed by the
810
- `messageFollow()`/`ScrollFollowModel` pairing.
811
-
812
- ## Pattern: A ColorPicker Composition
673
+ interface Turn {
674
+ id: string;
675
+ text: string;
676
+ mine: boolean;
677
+ }
813
678
 
814
- `ColorPicker.Dialog` hosts whichever picking surfaces a page wants. Each part operates on its
815
- own through its native range or text input, and sharing one live color across the composition
816
- is the island's job — it listens for each part's change event and re-renders the others:
679
+ export default clientEntry(
680
+ "/components/thread.tsx#default",
681
+ function Thread(handle: Handle<{ turns: Turn[] }>) {
682
+ let model = new ScrollFollowModel({ pinned: true });
817
683
 
818
- ```tsx
819
- import { ColorArea, ColorField, ColorPicker, ColorWheel } from "@sdxc/ui";
820
- import { colorAreaDrag, colorPreview, colorWheelDrag } from "@sdxc/ui/mixins";
821
-
822
- <ColorPicker.Dialog id="brandColor-panel">
823
- <ColorArea
824
- aria-label={t("colorPicker.area")}
825
- hue={hue}
826
- defaultSaturation={saturation}
827
- defaultValue={brightness}
828
- mix={colorAreaDrag()}
829
- >
830
- <ColorArea.SaturationThumb data-color-area-axis="x" aria-label={t("colorPicker.saturation")} />
831
- <ColorArea.ValueThumb data-color-area-axis="y" aria-label={t("colorPicker.brightness")} />
832
- </ColorArea>
833
-
834
- <ColorWheel aria-label={t("colorPicker.hue")} defaultValue={hue} mix={colorWheelDrag()} />
835
- <ColorField label={t("colorPicker.hex")} format="hex" mix={colorPreview()} />
836
- </ColorPicker.Dialog>;
684
+ return () => (
685
+ <MessageScroller mix={css({ blockSize: "32rem" })}>
686
+ <MessageScroller.Viewport mix={messageFollow(model)}>
687
+ <MessageScroller.Content>
688
+ {handle.props.turns.map((turn) => (
689
+ <MessageScroller.Item key={turn.id} messageId={turn.id}>
690
+ <Message>
691
+ <Message.Content>
692
+ <Bubble align={turn.mine ? "end" : "start"} variant="muted">
693
+ <Bubble.Content>{turn.text}</Bubble.Content>
694
+ </Bubble>
695
+ </Message.Content>
696
+ </Message>
697
+ </MessageScroller.Item>
698
+ ))}
699
+ </MessageScroller.Content>
700
+ </MessageScroller.Viewport>
701
+ <MessageScroller.Button aria-label="Jump to latest">Latest</MessageScroller.Button>
702
+ </MessageScroller>
703
+ );
704
+ },
705
+ );
837
706
  ```
838
707
 
839
- `ColorSlider` and `ColorSwatchPicker` drop into the same panel for a per-channel track and a
840
- preset row. `ColorArea.SaturationThumb` and `.ValueThumb` carry an explicit
841
- `data-color-area-axis` so `colorAreaDrag()` can pair them. Server-rendered alone, each part
842
- still works through keyboard and native range operation; the island is what keeps the
843
- siblings in sync.
844
-
845
- ## Pattern: Development-Mode Contract Warnings
846
-
847
- Where the type system cannot enforce a required accessibility wiring, a component logs a
848
- `console.warn` gated behind `import.meta.env.DEV`, stripped entirely from production
849
- bundles — an icon-only `Button` or `Menu.Item` with no visible text and no `aria-label`, a
850
- `Command.Item` rendered without the `value` a filter matches against, a `Menubar`,
851
- `Toast.Region` or `Table` rendered without the `aria-label`/`aria-labelledby` identifying the
852
- landmark, a `Dialog` rendered without the `id` a trigger's `commandfor` targets. These are a
853
- development-time nudge rather than runtime validation, so rendering continues either way.
708
+ `messageId` is unique per turn; `scrollAnchor` on an item keeps that turn in place while earlier ones
709
+ load above it.
854
710
 
855
711
  ## Versioning
856
712