@jonmilner/ui 0.21.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/Alert/Alert.css +2 -0
- package/dist/Alert/Alert.css.mjs +9 -0
- package/dist/Alert/index.d.mts +13 -0
- package/dist/Alert/index.mjs +45 -0
- package/dist/AlertDialog/client.mjs +4 -4
- package/dist/AlertDialog/index.d.mts +3 -2
- package/dist/AlertDialog/index.mjs +10 -9
- package/dist/Avatar/Avatar.css +1 -1
- package/dist/Avatar/index.d.mts +1 -1
- package/dist/Avatar/index.mjs +5 -5
- package/dist/Badge/Badge.css +1 -1
- package/dist/Badge/index.d.mts +1 -1
- package/dist/Badge/index.mjs +12 -12
- package/dist/Body/index.d.mts +9 -0
- package/dist/Body/index.mjs +12 -0
- package/dist/Box/Box.css +1 -1
- package/dist/Box/index.mjs +1 -1
- package/dist/Button/Button.css +1 -1
- package/dist/Button/index.d.mts +1 -1
- package/dist/Button/index.mjs +22 -22
- package/dist/Caption/index.d.mts +6 -0
- package/dist/Caption/index.mjs +14 -0
- package/dist/Checkbox/Checkbox.css +1 -1
- package/dist/Checkbox/index.mjs +7 -7
- package/dist/Chip/Chip.css +1 -1
- package/dist/Chip/index.mjs +35 -35
- package/dist/Clickable/Clickable.css +1 -1
- package/dist/Clickable/index.d.mts +1 -1
- package/dist/Clickable/index.mjs +4 -4
- package/dist/Code/Code.css +2 -0
- package/dist/Code/Code.css.mjs +7 -0
- package/dist/Code/index.d.mts +10 -0
- package/dist/Code/index.mjs +40 -0
- package/dist/ColorField/ColorField.css +2 -2
- package/dist/ColorField/client.mjs +6 -6
- package/dist/ColorField/index.mjs +14 -14
- package/dist/Combobox/Combobox.css +2 -2
- package/dist/Combobox/client.mjs +26 -26
- package/dist/Combobox/index.mjs +20 -20
- package/dist/Dialog/Dialog.css +2 -2
- package/dist/Dialog/client.d.mts +1 -1
- package/dist/Dialog/client.mjs +30 -28
- package/dist/Dialog/index.d.mts +2 -2
- package/dist/Dialog/index.mjs +19 -19
- package/dist/Field/Field.css +1 -1
- package/dist/Field/client.mjs +6 -6
- package/dist/Field/index.mjs +29 -29
- package/dist/Flex/index.d.mts +5 -0
- package/dist/Flex/index.mjs +14 -0
- package/dist/Heading/Heading.css +1 -1
- package/dist/Icon/Icon.css +1 -1
- package/dist/IconButton/IconButton.css +2 -2
- package/dist/IconButton/IconButton.css.mjs +2 -2
- package/dist/IconButton/index.d.mts +5 -2
- package/dist/IconButton/index.mjs +60 -21
- package/dist/Inline/Inline.css +1 -1
- package/dist/Inline/index.d.mts +2 -2
- package/dist/Inline/index.mjs +4 -4
- package/dist/Label/index.d.mts +9 -0
- package/dist/Label/index.mjs +19 -0
- package/dist/Menu/Menu.css +2 -2
- package/dist/Menu/Menu.css.mjs +1 -1
- package/dist/Menu/client.d.mts +1 -0
- package/dist/Menu/client.mjs +83 -62
- package/dist/Menu/index.d.mts +8 -0
- package/dist/Menu/index.mjs +123 -87
- package/dist/Menu/item-row.mjs +2 -2
- package/dist/MultiSelect/MultiSelect.css +2 -2
- package/dist/MultiSelect/client.mjs +4 -4
- package/dist/MultiSelect/index.mjs +8 -8
- package/dist/NavList/NavList.css +2 -2
- package/dist/NavList/client.mjs +3 -3
- package/dist/NavList/index.d.mts +3 -3
- package/dist/NavList/index.mjs +67 -65
- package/dist/NumberField/NumberField.css +2 -2
- package/dist/NumberField/index.mjs +17 -17
- package/dist/Popover/Popover.css +2 -0
- package/dist/Popover/Popover.css.mjs +7 -0
- package/dist/Popover/client.d.mts +11 -0
- package/dist/Popover/client.mjs +54 -0
- package/dist/Popover/index.d.mts +20 -0
- package/dist/Popover/index.mjs +39 -0
- package/dist/RadioGroup/RadioGroup.css +1 -1
- package/dist/RadioGroup/index.mjs +23 -23
- package/dist/SearchField/SearchField.css +2 -2
- package/dist/SearchField/client.mjs +13 -13
- package/dist/SearchField/index.mjs +16 -16
- package/dist/Select/Select.css +2 -2
- package/dist/Select/client.mjs +11 -11
- package/dist/Select/index.mjs +8 -8
- package/dist/Sidebar/Sidebar.css +1 -1
- package/dist/Sidebar/index.d.mts +1 -1
- package/dist/Sidebar/index.mjs +21 -21
- package/dist/SidebarLayout/SidebarLayout.css +1 -1
- package/dist/SidebarLayout/index.d.mts +1 -1
- package/dist/SidebarLayout/index.mjs +8 -8
- package/dist/Stack/Stack.css +1 -1
- package/dist/Stack/index.d.mts +2 -2
- package/dist/Stack/index.mjs +4 -4
- package/dist/Switch/Switch.css +1 -1
- package/dist/Switch/index.mjs +13 -13
- package/dist/Table/Table.css +2 -2
- package/dist/Table/Table.css.mjs +4 -2
- package/dist/Table/index.d.mts +4 -10
- package/dist/Table/index.mjs +80 -94
- package/dist/Tabs/Tabs.css +1 -1
- package/dist/Tabs/index.mjs +26 -26
- package/dist/Tag/Tag.css +1 -1
- package/dist/Tag/index.d.mts +1 -1
- package/dist/Tag/index.mjs +16 -16
- package/dist/Text/Text.css +1 -1
- package/dist/Text/index.d.mts +2 -2
- package/dist/Text/index.mjs +4 -4
- package/dist/TextField/TextField.css +2 -2
- package/dist/TextField/index.mjs +16 -16
- package/dist/Textarea/Textarea.css +2 -2
- package/dist/Textarea/index.mjs +9 -9
- package/dist/Toast/Toast.css +2 -2
- package/dist/Toast/Toast.css.mjs +10 -7
- package/dist/Toast/client.d.mts +5 -19
- package/dist/Toast/client.mjs +117 -152
- package/dist/Tooltip/Tooltip.css +1 -1
- package/dist/Tooltip/base.mjs +13 -13
- package/dist/VisuallyHidden/VisuallyHidden.css +1 -1
- package/dist/base.css +2 -2
- package/dist/brands/default.mjs +2 -1
- package/dist/brands/forced-colors.mjs +2 -1
- package/dist/brands/neutral.mjs +8 -7
- package/dist/contrast/contrast.d.mts +1 -1
- package/dist/contrast/contrast.mjs +42 -34
- package/dist/contrast/mixes.mjs +37 -30
- package/dist/docs/Alert.md +106 -0
- package/dist/docs/AlertDialog.md +25 -11
- package/dist/docs/Body.md +74 -0
- package/dist/docs/Box.md +4 -3
- package/dist/docs/Caption.md +77 -0
- package/dist/docs/Code.md +84 -0
- package/dist/docs/ColorField.md +1 -1
- package/dist/docs/Combobox.md +3 -1
- package/dist/docs/Dialog.md +28 -4
- package/dist/docs/Flex.md +76 -0
- package/dist/docs/Icon.md +1 -0
- package/dist/docs/IconButton.md +9 -1
- package/dist/docs/Inline.md +3 -2
- package/dist/docs/Label.md +77 -0
- package/dist/docs/Menu.md +54 -6
- package/dist/docs/MultiSelect.md +2 -0
- package/dist/docs/NavList.md +2 -2
- package/dist/docs/NumberField.md +1 -1
- package/dist/docs/Popover.md +135 -0
- package/dist/docs/SearchField.md +1 -1
- package/dist/docs/Select.md +2 -0
- package/dist/docs/Stack.md +12 -10
- package/dist/docs/Table.md +5 -5
- package/dist/docs/Text.md +30 -23
- package/dist/docs/TextField.md +1 -1
- package/dist/docs/Textarea.md +1 -1
- package/dist/docs/Toast.md +14 -7
- package/dist/docs/Tooltip.md +2 -2
- package/dist/docs/lint.md +18 -0
- package/dist/docs/llms.txt +20 -11
- package/dist/docs/manifest.json +732 -65
- package/dist/docs/migrations/0.22.0.md +35 -0
- package/dist/docs/migrations/0.23.0.md +84 -0
- package/dist/docs/theming.md +3 -3
- package/dist/icons/TriangleAlertIcon.d.mts +2 -0
- package/dist/icons/TriangleAlertIcon.mjs +10 -0
- package/dist/icons/index.d.mts +6 -5
- package/dist/icons/index.mjs +35 -34
- package/dist/index.d.mts +24 -16
- package/dist/index.mjs +47 -40
- package/dist/lint/index.d.mts +20 -1
- package/dist/lint/index.mjs +19 -3
- package/dist/popup/client.d.mts +1 -1
- package/dist/popup/client.mjs +59 -41
- package/dist/popup/direction.d.mts +2 -0
- package/dist/popup/direction.mjs +23 -0
- package/dist/popup/listbox-base.mjs +24 -24
- package/dist/popup/listbox-options.mjs +4 -4
- package/dist/popup/listbox-row.mjs +1 -0
- package/dist/popup/positioner.mjs +27 -0
- package/dist/popup/tooltip.d.mts +1 -0
- package/dist/popup/tooltip.mjs +48 -42
- package/dist/scroll-region/scroll-region.d.mts +12 -0
- package/dist/scroll-region/scroll-region.mjs +29 -0
- package/dist/status-message/status-message.d.mts +5 -0
- package/dist/status-message/status-message.mjs +74 -0
- package/dist/status-message/tones.d.mts +7 -0
- package/dist/status-message/tones.mjs +8 -0
- package/dist/styles/atom-values.mjs +131 -0
- package/dist/styles/atoms.css +1 -1
- package/dist/styles/layers.css +1 -1
- package/dist/styles/responsive.css +1 -1
- package/dist/styles/scroll-region.css +2 -0
- package/dist/styles/scroll-region.css.mjs +7 -0
- package/dist/styles/status-message.css +2 -0
- package/dist/styles/status-message.css.mjs +7 -0
- package/dist/theme/define-theme.mjs +42 -42
- package/dist/tokens/contract.d.mts +1 -1
- package/dist/tokens/roles.d.mts +1 -1
- package/dist/tokens/roles.mjs +1 -1
- package/package.json +30 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Code
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Code in the mono font: a run inside a line of text, or with `block` a multi-line sample on a muted surface. A `Text` preset, so it takes Text's props and the style props. No syntax highlighting, copy button, line numbers or wrapping.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- A file name, command, identifier or value inside a sentence: `<Code>`.
|
|
10
|
+
- A multi-line sample (a command, a config, a log excerpt) that keeps its line breaks: `<Code block>`.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- Prose in the mono font that is not code: use `Text` with `font="mono"`.
|
|
15
|
+
- A long log that should wrap: use `Text as="pre"` with `wrap="pre-wrap"`; a block never wraps.
|
|
16
|
+
- Highlighted code, a copy button or line numbers: not supported.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- Inline renders `<code>` in the `mono` font. It sets no size or color and has no background, so it inherits the line's; it inherits them only directly inside a `Text`, where it is a `Text` run (see `Text`). Outside one (a `Button` label, a bare `li`, a `Box`) it is a top-level `Text` at the default size and color, so put it in a `Text`.
|
|
21
|
+
- Inline takes Text's props (`size`, `weight`, `color`, `font`) and overrides its defaults with them.
|
|
22
|
+
- `block` renders `<pre><code>` at `sm` on `bgMuted` with the `med` radius and `12` by `16` padding. Line breaks and runs of spaces stay, lines never wrap, and a long line scrolls sideways inside the block, never the page.
|
|
23
|
+
- A block's type requires a name, `aria-label` or `aria-labelledby` (never both), as `Table.ScrollArea`'s does: the scroll region is a `section`, so the name makes it a region landmark. It is in the tab order only while the code overflows, and the arrow keys then scroll it.
|
|
24
|
+
- A block takes the style props (on the surface), `className` and `style` (on the surface), and the `section`'s other props, `ref` included. It takes no block size.
|
|
25
|
+
- A block is `dir="ltr"`, scrollbar included, so a right-to-left page neither reorders the code nor opens it scrolled to the far edge.
|
|
26
|
+
- Children are text: put the code in a string or template literal, not markup.
|
|
27
|
+
- Both forms are hook-free.
|
|
28
|
+
|
|
29
|
+
## Do
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<Text>
|
|
33
|
+
Run <Code>pnpm check</Code> before you push.
|
|
34
|
+
</Text>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Code block aria-label="Install command">
|
|
39
|
+
{`pnpm add @jonmilner/ui
|
|
40
|
+
pnpm exec local-ci run`}
|
|
41
|
+
</Code>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Don't
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// A block with no name does not type-check; the scroll region needs one.
|
|
48
|
+
<Code block>{sample}</Code>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
// Markup for color is highlighting, which Code does not do.
|
|
53
|
+
<Code block aria-label="Sample">
|
|
54
|
+
<span style={{ color: "red" }}>error</span>
|
|
55
|
+
</Code>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Accessibility
|
|
59
|
+
|
|
60
|
+
- A block that overflows is focusable, so a keyboard reaches it and scrolls it with the arrow keys; it shows the shared focus ring, inset so a dialog body does not clip it.
|
|
61
|
+
- Under forced colors the block gets a 1px `CanvasText` outline, inset, because its fill and radius vanish.
|
|
62
|
+
- The name says what the sample is (`Install command`), not that it is code.
|
|
63
|
+
- Under forced colors the scroll thumb keeps its fill.
|
|
64
|
+
|
|
65
|
+
## Props
|
|
66
|
+
|
|
67
|
+
Generated from the TypeScript types.
|
|
68
|
+
|
|
69
|
+
### Code
|
|
70
|
+
|
|
71
|
+
| Prop | Type | Required | Description |
|
|
72
|
+
| --- | --- | --- | --- |
|
|
73
|
+
| `aria-label` | `string` | no | The region's name. Required unless `aria-labelledby` names it. |
|
|
74
|
+
| `aria-labelledby` | `string` | no | The id of the element that names the region. Required unless `aria-label` names it. |
|
|
75
|
+
| `block` | `false \| true` | no | |
|
|
76
|
+
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
77
|
+
| `leading` | `"body" \| "lg" \| "med" \| "meta" \| "sm"` | no | |
|
|
78
|
+
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
79
|
+
| `tabularNums` | `boolean` | no | |
|
|
80
|
+
| `truncate` | `"box" \| boolean` | no | |
|
|
81
|
+
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
82
|
+
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
83
|
+
|
|
84
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/ColorField.md
CHANGED
|
@@ -67,7 +67,7 @@ A form field for one colour as a `#rrggbb` string: a swatch, the browser's own c
|
|
|
67
67
|
|
|
68
68
|
- The hex input is a `textbox` named by the label, visible or not; the swatch is the browser's colour input, named by `swatchLabel`. The swatch comes first in the tab order and opens the platform picker with Enter or Space.
|
|
69
69
|
- The colour shows as a filled square with a border, so a pale or dark colour stays visible on any background; the hex beside it says the colour in text.
|
|
70
|
-
- Invalid adds a danger border and the error message with its icon, never colour alone; disabled adds dashed borders. Under forced colors the swatch keeps its colour, since the colour is the content, and its border uses a system colour. On a coarse pointer (a touch screen) the hex text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
70
|
+
- Invalid adds a 2px danger border, a 2px `CanvasText` border under forced colors, and the error message with its icon, never colour alone; disabled adds dashed borders. Under forced colors the swatch keeps its colour, since the colour is the content, and its border uses a system colour. On a coarse pointer (a touch screen) the hex text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
71
71
|
|
|
72
72
|
## Props
|
|
73
73
|
|
package/dist/docs/Combobox.md
CHANGED
|
@@ -32,6 +32,7 @@ A form field for picking one value, or any number with `multiple`, from a list l
|
|
|
32
32
|
- `disabled` disables the trigger and mutes the label. `required` marks the field required; report a missing value through `error`.
|
|
33
33
|
- The trigger, the popup and its listbox are named by `label`; the filter input by `filterLabel`.
|
|
34
34
|
- Style props, `className` and `style` go to the `Field` around the label, trigger and messages, not to the trigger or the popup.
|
|
35
|
+
- The popup stops 8px from the viewport's edges. A long option's label wraps, breaking inside a URL or hash if it has to, so there is no need to shorten labels or set a width to fit them.
|
|
35
36
|
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode. That provider must not clip or stack its content: wrap the app root, and keep a nested provider off elements with `overflow: hidden`, a `transform` or their own `z-index`. It sits on `zIndex` `popover`, below the trigger by default, and flips when it would overflow the viewport. The input stays at its top while the options scroll.
|
|
36
37
|
- Never add key handlers or `tabIndex`; Base UI handles the keyboard.
|
|
37
38
|
- The module has no hooks, so a server component can render it; `onValueChange` must come from a client component.
|
|
@@ -90,6 +91,7 @@ A form field for picking one value, or any number with `multiple`, from a list l
|
|
|
90
91
|
- A closed popup stays on the page while it fades out, but is `inert` and `aria-hidden` from the moment it closes, so a popup opened during the fade is the only one a screen reader or a role query finds (ADR 0113).
|
|
91
92
|
- Selection is a check mark on the option as well as the trigger's text, so it is not color alone. The check sits at the end of the row; its space is always kept, so labels never shift.
|
|
92
93
|
- The trigger summary is text: the label, the joined labels, or the count. When the count replaces the labels, the labels are hidden from assistive technology so the count is read once.
|
|
94
|
+
- Invalid adds a 2px danger border on the trigger, a 2px `CanvasText` border under forced colors, and the error message with its icon, never colour alone. While the focus ring shows, it replaces the border's second pixel.
|
|
93
95
|
- The highlighted option takes the shared highlight fill. Under forced colors it is `Highlight` with `HighlightText`, the input's ring is `Highlight`, and the popup keeps its border.
|
|
94
96
|
|
|
95
97
|
## Props
|
|
@@ -110,7 +112,7 @@ Generated from the TypeScript types.
|
|
|
110
112
|
| `filterLabel` | `string` | no | |
|
|
111
113
|
| `hideLabel` | `boolean` | no | |
|
|
112
114
|
| `label` | `ReactNode` | yes | |
|
|
113
|
-
| `multiple` | `
|
|
115
|
+
| `multiple` | `false \| true` | no | |
|
|
114
116
|
| `name` | `string` | no | |
|
|
115
117
|
| `onValueChange` | `((value: string \| null) => void) \| ((value: string[]) => void)` | no | |
|
|
116
118
|
| `options` | `readonly ListboxOption[]` | yes | |
|
package/dist/docs/Dialog.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
A modal panel over the page for one short task: edit a name, fill a small form, read details that need a decision. Built on Base UI's Dialog, which owns the behavior: focus moves into the dialog and stays there, the page behind is
|
|
5
|
+
A modal panel over the page for one short task: edit a name, fill a small form, read details that need a decision. Built on Base UI's Dialog, which owns the behavior: focus moves into the dialog and stays there, the page behind is hidden from assistive tech and does not scroll, Esc and a click on the backdrop close it, and focus returns to the trigger. The parts add the look: a dimmed backdrop, a raised panel with a title, and a zoom-and-fade that is a plain fade under reduced motion.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ A modal panel over the page for one short task: edit a name, fill a small form,
|
|
|
13
13
|
|
|
14
14
|
- Confirming something destructive or irreversible: use `AlertDialog`, which focuses Cancel and ignores outside clicks.
|
|
15
15
|
- A list of actions: use `Menu`.
|
|
16
|
-
- Content the user wants beside the page, or a hint: use
|
|
16
|
+
- Content the user wants beside the page, or a hint: use `Popover` or inline text; a modal blocks the page.
|
|
17
17
|
- A long flow or a lot of content: give it a page.
|
|
18
18
|
- A status message or the result of an action: use `Toast`, which leaves focus where it is; a dialog takes it.
|
|
19
19
|
|
|
@@ -29,6 +29,7 @@ A modal panel over the page for one short task: edit a name, fill a small form,
|
|
|
29
29
|
- Control it with `open` and `onOpenChange` to close it after a save or keep it open on an error. `onOpenChangeComplete` runs once the exit transition ends.
|
|
30
30
|
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode. That provider must not clip or stack its content: wrap the app root, and keep a nested provider off elements with `overflow: hidden`, a `transform` or their own `z-index`. It sits on `zIndex` `modal`. A dialog opened only through `open`, with no `Dialog.Trigger`, has no provider to find and portals to `<body>`.
|
|
31
31
|
- It is always modal. Never add key handlers, `tabIndex` or your own focus trap to the parts.
|
|
32
|
+
- `finalFocus` on `Dialog.Popup` sends focus elsewhere on close. A ref, to the focusable control itself, gets focus at once, with a visible focus ring after a key, and an empty one falls back to the trigger; a function's target gets focus when the fade ends; `false` returns no focus (ADR 0192).
|
|
32
33
|
- The module has no hooks, so a server component can render the parts; `onOpenChange` and other functions must come from a client component.
|
|
33
34
|
|
|
34
35
|
## Do
|
|
@@ -98,10 +99,33 @@ const [open, setOpen] = useState(false);
|
|
|
98
99
|
## Accessibility
|
|
99
100
|
|
|
100
101
|
- The trigger has `aria-haspopup="dialog"` and `aria-expanded`. The popup is `role="dialog"` with `aria-modal`, labelled by the title and described by the description.
|
|
101
|
-
- Opening moves focus into the popup; Tab and Shift+Tab cycle inside it, and the page behind is
|
|
102
|
+
- Opening moves focus into the popup; Tab and Shift+Tab cycle inside it, and the page behind is `aria-hidden`. Esc or a backdrop click closes it, and focus returns to the trigger.
|
|
102
103
|
- A closed dialog stays on the page while it fades out, but is `inert` and `aria-hidden` from the moment it closes, and focus is back on the trigger at once, so a dialog opened during the fade is the only one a screen reader or a role query finds, and nothing in the fading one takes focus or a click (ADR 0113).
|
|
103
104
|
- The panel takes the shared focus ring when focused from the keyboard. Under forced colors it keeps its border, so it stays apart from the page.
|
|
104
|
-
- The backdrop is
|
|
105
|
+
- The backdrop is the `backdrop` color role over the page; it only dims, and carries no text. In the presets that is 40% near-black in light mode and 70% black in dark. Under forced colors it has no fill.
|
|
106
|
+
|
|
107
|
+
## Theming
|
|
108
|
+
|
|
109
|
+
To change how far the backdrop dims, set the `backdrop` color role in the brand you pass to `defineTheme`, or override `--color-backdrop` on `[data-brand]` from `@layer app` under a preset. A rule on `:root` has no effect, since the brand's own block is closer. No selector on the portal's DOM is needed.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
const theme = defineTheme({
|
|
113
|
+
...defaultBrand,
|
|
114
|
+
name: "inbox",
|
|
115
|
+
color: {
|
|
116
|
+
...defaultBrand.color,
|
|
117
|
+
backdrop: "light-dark(oklch(0.145 0 0 / 0.5), oklch(0 0 0 / 0.8))",
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```css
|
|
123
|
+
@layer app {
|
|
124
|
+
[data-brand] {
|
|
125
|
+
--color-backdrop: light-dark(oklch(0.145 0 0 / 0.5), oklch(0 0 0 / 0.8));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
105
129
|
|
|
106
130
|
## Props
|
|
107
131
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Flex
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
The flex primitive `Stack` and `Inline` are built from: a `Box` with `display="flex"` as a default style prop. It takes every `Box` prop, adds none, and has no class of its own, so `<Flex>` renders exactly `<Box display="flex">`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Building a layout component that is a flex container, as `Stack` and `Inline` are.
|
|
10
|
+
- Almost never in an app: `Flex` there, like `display: flex` in a stylesheet, is a code smell, since a flex layout is a `Stack` or an `Inline`.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- A column of children with a gap: use `Stack`.
|
|
15
|
+
- A row of children with a gap, wrapping or not: use `Inline` (`flexWrap="nowrap"` keeps it on one line).
|
|
16
|
+
- A row whose ends sit apart, such as a title and its actions: use `Inline` with `flexWrap="nowrap"` and `justifyContent="space-between"`.
|
|
17
|
+
- A two-dimensional layout: use `Box` with `display="grid"`.
|
|
18
|
+
- A page with a sidebar: use `SidebarLayout`.
|
|
19
|
+
- A surface with padding or a background and no flex layout: use `Box`.
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
- `display` defaults to `flex`; set it to override, such as `display={{ base: "none", med: "flex" }}`. `null` or `false` drops it, as on `Box`.
|
|
24
|
+
- There are no shorthand props such as `direction` or `align`: use the style props `flexDirection`, `alignItems`, `justifyContent`, `flexWrap` and `gap`.
|
|
25
|
+
- Polymorphic with `as`; the consumer's `className` and `style` pass through, and `ref` is a plain prop typed for the `as` element.
|
|
26
|
+
|
|
27
|
+
## Do
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<Inline flexWrap="nowrap" gap="8" justifyContent="space-between">
|
|
31
|
+
<Heading>Invoices</Heading>
|
|
32
|
+
<Button>New invoice</Button>
|
|
33
|
+
</Inline>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
// Building a layout component: Flex with its layout as default style props, as Stack is.
|
|
38
|
+
function Cluster<T extends ElementType = "div">({ flexWrap = "wrap", ...props }: FlexProps<T>) {
|
|
39
|
+
return <Flex<ElementType> flexWrap={flexWrap} {...props} />;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Don't
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
// Flex rebuilding Stack: use `<Stack gap="16">`.
|
|
47
|
+
<Flex flexDirection="column" gap="16">
|
|
48
|
+
<Label>Name</Label>
|
|
49
|
+
<Label>Email</Label>
|
|
50
|
+
</Flex>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// Flex rebuilding Inline: use `<Inline gap="8">`.
|
|
55
|
+
<Flex alignItems="center" flexWrap="wrap" gap="8">
|
|
56
|
+
<Tag>design</Tag>
|
|
57
|
+
<Tag>tokens</Tag>
|
|
58
|
+
</Flex>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Accessibility
|
|
62
|
+
|
|
63
|
+
- Flex adds no role or ARIA. Pick the element with `as`.
|
|
64
|
+
- Visual order is source order; do not reverse it with `flexDirection` to reorder meaningful content, since reading and focus order follow the source.
|
|
65
|
+
|
|
66
|
+
## Props
|
|
67
|
+
|
|
68
|
+
Generated from the TypeScript types.
|
|
69
|
+
|
|
70
|
+
### Flex
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Required | Description |
|
|
73
|
+
| --- | --- | --- | --- |
|
|
74
|
+
| `as` | `ElementType` | no | |
|
|
75
|
+
|
|
76
|
+
Also accepts every `<div>` attribute (change the element with `as`) and the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/Icon.md
CHANGED
|
@@ -103,6 +103,7 @@ Generated from `src/icons/svg/` and exported from `@jonmilner/ui/icons`; each ta
|
|
|
103
103
|
- `SearchIcon` (`search.svg`)
|
|
104
104
|
- `SettingsIcon` (`settings.svg`)
|
|
105
105
|
- `Trash2Icon` (`trash-2.svg`)
|
|
106
|
+
- `TriangleAlertIcon` (`triangle-alert.svg`)
|
|
106
107
|
- `XIcon` (`x.svg`)
|
|
107
108
|
|
|
108
109
|
<!-- icons:end -->
|
package/dist/docs/IconButton.md
CHANGED
|
@@ -22,7 +22,8 @@ A compact button whose only visible content is an icon, for an action the icon m
|
|
|
22
22
|
- `icon` takes an icon component (a generated `XIcon`, or a component that renders `Icon`), not an element: IconButton renders it at the `fontSize` step one below its `size` (12, 14 and 16px at `sm`, `med`, `lg`), as Button's icons, `aria-hidden`.
|
|
23
23
|
- `variant`: `ghost` (default), a muted ghost: no fill, border or glow, an `fgMuted` icon that turns `fg` on hover, keyboard focus and while open, for most icon actions, toolbars and controls that already frame it (SearchField's clear button). `secondary`, Button's quiet `controlFill` look, for an icon action that needs a visible frame; `primary` for the one action a view or dialog exists for. There is no `tone` and no `danger`: a destructive action deserves a labelled `Button` (ADR 0163).
|
|
24
24
|
- `size`: `sm`, `med` (default) or `lg`, never `md`. Each is a square as wide as Button's height of the same name (24, 32 and 40px), so an IconButton lines up with a Button beside it.
|
|
25
|
-
- `disabled` renders `aria-disabled="true"` and a dashed border, never the native `disabled`. There is no
|
|
25
|
+
- `disabled` renders `aria-disabled="true"` and a dashed border, never the native `disabled`. There is no tooltip.
|
|
26
|
+
- `loading` shows Button's three pulsing dots in place of the icon, in the same square, and renders `aria-busy="true"`: the button stays focusable, keeps its size and `label`, and blocks click, Enter and Space. A raw `aria-busy` counts as `loading`. On the muted `ghost` the dots are `fg`, or the passed `color`. The dots hold still under `prefers-reduced-motion: reduce` (ADR 0179).
|
|
26
27
|
- With `aria-expanded="true"`, as a Dialog trigger sets it, it holds the hover tint and an inset ring while the popup is open, as Button does.
|
|
27
28
|
- Fill (`backgroundColor`), text color (`color`), width (`minInlineSize`), height (`minBlockSize`) and `borderRadius` (`sm`) are default style props: pass one to change it. Change width and height together to keep the square. A `color` replaces the muted ghost's `fgMuted` and its `fg` on hover. `primary`'s glow gives way to a `boxShadow` prop, as on Button. Hover tints whatever the fill is; a custom fill needs an icon color that passes 3:1 on it (4.5:1 to match Button).
|
|
28
29
|
- `as="a"` with `href` for an icon-only link.
|
|
@@ -41,6 +42,10 @@ A compact button whose only visible content is an icon, for an action the icon m
|
|
|
41
42
|
</Inline>
|
|
42
43
|
```
|
|
43
44
|
|
|
45
|
+
```tsx
|
|
46
|
+
<IconButton label="Merge" icon={GitMergeIcon} loading={merging} onClick={merge} />
|
|
47
|
+
```
|
|
48
|
+
|
|
44
49
|
## Don't
|
|
45
50
|
|
|
46
51
|
```tsx
|
|
@@ -63,6 +68,7 @@ A compact button whose only visible content is an icon, for an action the icon m
|
|
|
63
68
|
- The `label` is announced as the button's name; the icon is hidden from assistive technology.
|
|
64
69
|
- The label is not shown on hover or focus. Sighted users who don't recognise the icon get no text, so keep IconButton to widely understood icons.
|
|
65
70
|
- A disabled IconButton stays in the tab order, and Enter and Space do nothing; the blocked click still bubbles to an ancestor's `onClick` (see Clickable's Rules). State is never color alone: disabled adds a dashed border.
|
|
71
|
+
- A loading IconButton is announced as busy under its `label`, stays in the tab order, and Enter and Space do nothing; the dots are hidden from assistive technology.
|
|
66
72
|
- Every size is at least 24 by 24 CSS px (WCAG 2.2 target size); the icon on each variant passes 4.5:1 at rest and on hover in light and dark modes. Under forced colors it keeps Button's system colors, `ghost`'s `CanvasText` border included, and drops `primary`'s glow.
|
|
67
73
|
|
|
68
74
|
## Props
|
|
@@ -73,10 +79,12 @@ Generated from the TypeScript types.
|
|
|
73
79
|
|
|
74
80
|
| Prop | Type | Required | Description |
|
|
75
81
|
| --- | --- | --- | --- |
|
|
82
|
+
| `aria-busy` | `"false" \| "true" \| boolean` | no | |
|
|
76
83
|
| `as` | `ElementType` | no | |
|
|
77
84
|
| `disabled` | `boolean` | no | |
|
|
78
85
|
| `icon` | `ComponentType` | yes | |
|
|
79
86
|
| `label` | `string` | yes | |
|
|
87
|
+
| `loading` | `boolean` | no | |
|
|
80
88
|
| `size` | `"lg" \| "med" \| "sm"` | no | |
|
|
81
89
|
| `variant` | `"ghost" \| "primary" \| "secondary"` | no | |
|
|
82
90
|
|
package/dist/docs/Inline.md
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
A horizontal row of children that wraps onto new lines, with even space between them on both axes. `Inline` is a `Box` with `display="flex"
|
|
5
|
+
A horizontal row of children that wraps onto new lines, with even space between them on both axes. `Inline` is a `Flex` (a `Box` with `display="flex"`) with `flexDirection="row"`, `flexWrap="wrap"` and `alignItems="center"` as default style props, spaced by a required `gap`. Children render as they are: no wrapper per child.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
9
9
|
- A group of buttons, tags, pills or badges: `<Inline gap="8">`.
|
|
10
10
|
- Metadata on one line that wraps when narrow: author, date, read time.
|
|
11
11
|
- An icon beside a label, centered on the cross axis.
|
|
12
|
+
- A row that must never wrap and splits space between its ends (a toolbar, a header bar): `<Inline flexWrap="nowrap" gap="8" justifyContent="space-between">`, not a `Box` or `Flex` rebuilt by hand, nor `display: flex` in a stylesheet.
|
|
13
|
+
- A list row that draws no marker: `<Inline as="li" gap="8">` in a `Stack as="ul"` with `paddingInlineStart="0"`, as Stack's docs show.
|
|
12
14
|
|
|
13
15
|
## When not to use
|
|
14
16
|
|
|
15
17
|
- A vertical column: use `Stack`.
|
|
16
|
-
- A row that must never wrap and splits space between ends (a toolbar, a header bar): use `Box` with `display="flex"` and `justifyContent="space-between"`, or pass `flexWrap="nowrap"`.
|
|
17
18
|
- A two-dimensional layout: use `Box` with `display="grid"`.
|
|
18
19
|
- A sidebar beside a page's main content: use `SidebarLayout`, which keeps the sidebar's width and stacks it when its container is narrow.
|
|
19
20
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Short UI text that names or tags something: a value's name in a summary, a status, a section's small title in a panel, the text beside an icon. A `Text` with label defaults: the `label` font role, `medium` weight, `sm` with the paired `body` leading, rendered as a `span`. It is not a form label.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- A few words that name what is next to them, in UI rather than prose.
|
|
10
|
+
- Text inside a custom control or a row you build from `Box` and `Inline`.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- A form control's label: use `Field.Label`, which ties the text to the control.
|
|
15
|
+
- A sentence or paragraph: use `Body`.
|
|
16
|
+
- A muted note (a timestamp, a count): use `Caption`.
|
|
17
|
+
- A heading in the document outline: use `Heading`.
|
|
18
|
+
- Inside a Button, Badge, Tag or Tab: they set their own text.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- `size` is `xs`, `sm` (default) or `med`. `xs` takes the `meta` leading (12/16) and `sm` the `body` leading (14/20), so the line box lands on the pixel grid; `med` keeps Text's.
|
|
23
|
+
- `as` defaults to `span`. On its own it is still a trimmed block (Text's default `display`); directly inside another Text it is an inline run at its own size.
|
|
24
|
+
- Label takes every other Text prop (`color`, `weight`, `font`, `truncate`, `wrap`, style props) and overrides its defaults with them.
|
|
25
|
+
- One line is the norm: set `truncate` or `wrap="nowrap"` where it must not break.
|
|
26
|
+
|
|
27
|
+
## Do
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<Inline alignItems="center" gap="8">
|
|
31
|
+
<RefreshCwIcon size="sm" />
|
|
32
|
+
<Label>Last synced</Label>
|
|
33
|
+
</Inline>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Label color="fgMuted" size="xs" wrap="nowrap">
|
|
38
|
+
Beta
|
|
39
|
+
</Label>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Don't
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
// Plain text labels nothing; a field's label is TextField's `label` or Field.Label.
|
|
46
|
+
<Label>Email</Label>
|
|
47
|
+
<input name="email" />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
// Labels stop at med; larger text is a Heading or Body.
|
|
52
|
+
<Label size="lg">Overview</Label>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Accessibility
|
|
56
|
+
|
|
57
|
+
- A Label is plain text: it names nothing for assistive technology. To name a control, use `Field.Label` or the control's own `aria-label`.
|
|
58
|
+
- Text that looks like a heading but is a Label is not in the outline; if users navigate to it, make it a `Heading`.
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
|
|
62
|
+
Generated from the TypeScript types.
|
|
63
|
+
|
|
64
|
+
### Label
|
|
65
|
+
|
|
66
|
+
| Prop | Type | Required | Description |
|
|
67
|
+
| --- | --- | --- | --- |
|
|
68
|
+
| `as` | `ElementType` | no | |
|
|
69
|
+
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
70
|
+
| `leading` | `"body" \| "lg" \| "med" \| "meta" \| "sm"` | no | |
|
|
71
|
+
| `size` | `"med" \| "sm" \| "xs"` | no | |
|
|
72
|
+
| `tabularNums` | `boolean` | no | |
|
|
73
|
+
| `truncate` | `"box" \| boolean` | no | |
|
|
74
|
+
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
75
|
+
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
76
|
+
|
|
77
|
+
Also accepts every `<span>` attribute (change the element with `as`) and the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/Menu.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a toolbar's overflow. It may mix in links ("Open invoice", "Download PDF") as `Menu.LinkItem`, real anchors that keep the browser's link behavior. Built on Base UI's Menu, which owns the keyboard and focus: arrow keys, Home and End move through the items, typing jumps to a matching item, Esc and an outside click close it, and focus returns to the trigger. The parts add the look: a raised surface with a border and shadow, a highlighted item, a zoom-and-fade that is a plain fade under reduced motion.
|
|
5
|
+
A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a toolbar's overflow. An entry can open a nested list. It may mix in links ("Open invoice", "Download PDF") as `Menu.LinkItem`, real anchors that keep the browser's link behavior. Built on Base UI's Menu, which owns the keyboard and focus: arrow keys, Home and End move through the items, typing jumps to a matching item, Esc and an outside click close it, and focus returns to the trigger. The parts add the look: a raised surface with a border and shadow, a highlighted item, a zoom-and-fade that is a plain fade under reduced motion.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
@@ -15,11 +15,11 @@ A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a
|
|
|
15
15
|
- Picking a value for a form field: use `Select` for one value from a long list, `RadioGroup` for one of a few (all shown) and `MultiSelect` for several.
|
|
16
16
|
- Navigation between pages: a menu that is only links is still navigation, so show the links on the page or in a `NavList`. Link items are for a menu that mixes actions and links.
|
|
17
17
|
- One or two actions: show them as buttons.
|
|
18
|
-
- Content a user reads, or anything interactive inside the list (fields, toggles): use
|
|
18
|
+
- Content a user reads, or anything interactive inside the list (fields, toggles): use `Popover` or `Dialog`.
|
|
19
19
|
|
|
20
20
|
## Rules
|
|
21
21
|
|
|
22
|
-
- Compose the parts: `Menu` > `Menu.Trigger` + `Menu.Popup` > `Menu.Item`, `Menu.LinkItem`, `Menu.Separator`, `Menu.Group`. `Menu` holds the open state and renders no element, so it takes no `className` or `style`; every other part does, plus style props.
|
|
22
|
+
- Compose the parts: `Menu` > `Menu.Trigger` + `Menu.Popup` > `Menu.Item`, `Menu.LinkItem`, `Menu.Separator`, `Menu.Group`, `Menu.SubmenuRoot`. `Menu` holds the open state and renders no element, so it takes no `className` or `style`; every other part does, plus style props.
|
|
23
23
|
- `Menu.Trigger` is a bare `Clickable`: give it its look with style props (or your own class), and an accessible name.
|
|
24
24
|
- For an icon-only trigger ("More actions"), pass `icon` and `label`: it renders an `IconButton`, the same square as one at each `size` (`sm`, `med`, `lg`; `med` by default), named by `label`, with IconButton's `variant` (the muted `ghost` by default, ADR 0163) and the open look below. It takes no children, `iconStart`, `iconEnd` or `aria-label` (ADR 0123). Never build one from `iconStart` and `aria-label`: Button's padding makes it wider than the IconButtons beside it.
|
|
25
25
|
- For a trigger that reads as a button ("Actions", "New"), pass Button's `variant`, `size`, `iconStart`, `iconEnd` or `uppercase` (a `ChevronDownIcon` for "Actions ▾"): it renders a `Button`, with its fill, border and height, and keeps the trigger's behavior and `aria-disabled`. While the menu is open it shows Button's open look, a held tint and an inset ring (ADR 0063); a bare trigger has none, so style it yourself off `aria-expanded`. Style props still override the defaults.
|
|
@@ -32,7 +32,8 @@ A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a
|
|
|
32
32
|
- `Menu.Separator` draws a line inside its own padding (`paddingBlock="4"`, `paddingInline="8"`) and sets no margin. Change its spacing with `paddingBlock` and `paddingInline` (the `padding` shorthand loses to these defaults, decision 0065); a `margin*` prop adds space outside the padding. `style={{ borderBlockStartColor }}` recolours the line.
|
|
33
33
|
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode. That provider must not clip or stack its content: wrap the app root, and keep a nested provider off elements with `overflow: hidden`, a `transform` or their own `z-index`, or the popup is clipped or drawn under siblings. It sits on `zIndex` `popover`. A menu opened only through `open`, with no `Menu.Trigger`, has no provider to find and portals to `<body>`.
|
|
34
34
|
- Item and link item text is wrapped in `Text` (`label`, `sm`) for you. `iconStart` and `iconEnd` take an icon component (`iconStart={PencilIcon}`), rendered at the label's size, 4px from it and centred on its cap height, as on Button, Badge and Tag (ADR 0152); the item is as tall as without them. With a `description` they stay on the label's line. Never put an icon in the children: they are the label only.
|
|
35
|
-
- `side` (`bottom` by default) and `align` (`start`) place the popup against the trigger; it flips when it would overflow the viewport.
|
|
35
|
+
- `side` (`bottom` by default, `inline-end` for a submenu's popup) and `align` (`start`) place the popup against the trigger; it flips when it would overflow the viewport.
|
|
36
|
+
- For a nested menu, put `Menu.SubmenuRoot` in a `Menu.Popup`, holding `Menu.SubmenuTrigger` and a `Menu.Popup` of its own. The trigger is a row with `Menu.Item`'s tokens, highlight, disabled and focus looks and a trailing chevron that flips under `rtl`; it takes `iconStart` and `description`, and no `iconEnd`. Never style a Base UI `SubmenuTrigger` to look like an item. `disabled` goes on `Menu.SubmenuRoot`, which disables its trigger too. `Menu.SubmenuRoot` takes `open`, `defaultOpen`, `onOpenChange`, `disabled`, `loopFocus` and `closeParentOnEsc`, which makes Esc close the whole menu rather than the one level. It renders no element, so it takes no `className`, `style` or style props.
|
|
36
37
|
- Never add key handlers or `tabIndex` to the parts; Base UI handles the keyboard.
|
|
37
38
|
- The module has no hooks, so a server component can render the parts; `onClick` and other functions must come from a client component.
|
|
38
39
|
|
|
@@ -109,6 +110,23 @@ A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a
|
|
|
109
110
|
</Menu.Popup>
|
|
110
111
|
```
|
|
111
112
|
|
|
113
|
+
```tsx
|
|
114
|
+
// "Repo settings" opens a nested list of repos beside the row.
|
|
115
|
+
<Menu.Popup>
|
|
116
|
+
<Menu.Item onClick={newProject}>New project</Menu.Item>
|
|
117
|
+
<Menu.SubmenuRoot>
|
|
118
|
+
<Menu.SubmenuTrigger>Repo settings</Menu.SubmenuTrigger>
|
|
119
|
+
<Menu.Popup>
|
|
120
|
+
{repos.map((repo) => (
|
|
121
|
+
<Menu.Item key={repo.id} onClick={() => open(repo)}>
|
|
122
|
+
{repo.name}
|
|
123
|
+
</Menu.Item>
|
|
124
|
+
))}
|
|
125
|
+
</Menu.Popup>
|
|
126
|
+
</Menu.SubmenuRoot>
|
|
127
|
+
</Menu.Popup>
|
|
128
|
+
```
|
|
129
|
+
|
|
112
130
|
## Don't
|
|
113
131
|
|
|
114
132
|
```tsx
|
|
@@ -162,6 +180,7 @@ A list of actions that opens from a button: a row's "Edit, Duplicate, Delete", a
|
|
|
162
180
|
- The trigger has `aria-haspopup="menu"` and `aria-expanded`; the popup is `role="menu"` labelled by the trigger, items and link items are `role="menuitem"` (a link item is an `<a>` with an `href`, so the browser treats it as a link), groups are `role="group"` named by their label.
|
|
163
181
|
- Opening from the keyboard focuses the first item; from the pointer, the popup. Focus stays in the menu until it closes. Closed by Esc, an item or `open={false}`, focus returns at once to the trigger that opened it, so a Tab pressed while it fades goes on to the control after the trigger. A press outside, a Tab out, a hover menu the pointer left, or a popup with `finalFocus` leaves focus to Base UI, which places it when the fade ends.
|
|
164
182
|
- A closed menu stays on the page while it fades out, but is `inert` and `aria-hidden` from the moment it closes, so a menu opened during the fade (the next row's) is the only one a screen reader or a role query finds, and nothing in the fading one takes focus or a click.
|
|
183
|
+
- A submenu trigger is `role="menuitem"` with `aria-haspopup="menu"` and `aria-expanded`, which Base UI drops while a keyboard-opened submenu is open on Apple platforms, so VoiceOver, if running, reads the item that takes focus; its popup is a `role="menu"` named by it. ArrowRight, Enter or Space opens it and focuses its first item; ArrowLeft or Esc closes that level and returns focus to the trigger. Under `rtl` the popup and chevron mirror, but the arrow keys stay left to right, as in every Menu (ADR 0175). Hovering the trigger opens it, and the pointer can cross into it without closing it. The trigger keeps its fill while its submenu is open.
|
|
165
184
|
- The icon trigger's name is its `label`, as `aria-label`.
|
|
166
185
|
- An item's `description` is its accessible description (`aria-describedby`), read after its name; the name stays the label alone. An `aria-describedby` of the item's own is kept, read after the description. With plain-text children, typeahead matches the label alone, not the description; otherwise pass `label`.
|
|
167
186
|
- The popup is never wider than the viewport beside its trigger, so at 320 px and 200% text a long item wraps inside it (WCAG 1.4.10).
|
|
@@ -255,12 +274,41 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
255
274
|
|
|
256
275
|
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
257
276
|
|
|
277
|
+
### Menu.SubmenuRoot
|
|
278
|
+
|
|
279
|
+
| Prop | Type | Required | Description |
|
|
280
|
+
| --- | --- | --- | --- |
|
|
281
|
+
| `children` | `ReactNode` | no | |
|
|
282
|
+
| `closeParentOnEsc` | `boolean` | no | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
|
|
283
|
+
| `defaultOpen` | `boolean` | no | Whether the menu is initially open. To render a controlled menu, use the `open` prop instead. |
|
|
284
|
+
| `disabled` | `boolean` | no | Whether the component should ignore user interaction. |
|
|
285
|
+
| `loopFocus` | `boolean` | no | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
|
|
286
|
+
| `onOpenChange` | `((open: boolean, eventDetails: MenuRootChangeEventDetails) => void)` | no | Event handler called when the menu is opened or closed. |
|
|
287
|
+
| `open` | `boolean` | no | Whether the menu is currently open. |
|
|
288
|
+
|
|
289
|
+
### Menu.SubmenuTrigger
|
|
290
|
+
|
|
291
|
+
| Prop | Type | Required | Description |
|
|
292
|
+
| --- | --- | --- | --- |
|
|
293
|
+
| `className` | `string` | no | |
|
|
294
|
+
| `closeDelay` | `number` | no | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
|
|
295
|
+
| `delay` | `number` | no | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
|
|
296
|
+
| `description` | `ReactNode` | no | |
|
|
297
|
+
| `iconStart` | `ComponentType` | no | |
|
|
298
|
+
| `id` | `string` | no | |
|
|
299
|
+
| `label` | `string` | no | Overrides the text used for keyboard text navigation and filtering. Falls back to the rendered text when not provided. |
|
|
300
|
+
| `onClick` | `((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)` | no | |
|
|
301
|
+
| `openOnHover` | `boolean` | no | Whether the menu should also open when the trigger is hovered. |
|
|
302
|
+
| `style` | `CSSProperties` | no | |
|
|
303
|
+
|
|
304
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
305
|
+
|
|
258
306
|
### Menu.Trigger
|
|
259
307
|
|
|
260
308
|
| Prop | Type | Required | Description |
|
|
261
309
|
| --- | --- | --- | --- |
|
|
262
|
-
| `aria-label` | `
|
|
263
|
-
| `aria-labelledby` | `
|
|
310
|
+
| `aria-label` | `undefined` | no | Defines a string value that labels the current element. |
|
|
311
|
+
| `aria-labelledby` | `undefined` | no | Identifies the element (or elements) that labels the current element. |
|
|
264
312
|
| `children` | `ReactNode` | no | |
|
|
265
313
|
| `closeDelay` | `number` | no | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
|
|
266
314
|
| `delay` | `number` | no | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
|
package/dist/docs/MultiSelect.md
CHANGED
|
@@ -31,6 +31,7 @@ A form field for picking any number of values from a list too long to show at on
|
|
|
31
31
|
- `disabled` takes the trigger out of the tab order and mutes the label. `required` sets `aria-required` on the trigger; report a missing value through `error`.
|
|
32
32
|
- The trigger and the open listbox are both named by `label`.
|
|
33
33
|
- Style props, `className` and `style` go to the `Field` around the label, trigger and messages, not to the trigger or the popup.
|
|
34
|
+
- The popup stops 8px from the viewport's edges. A long option's label wraps, breaking inside a URL or hash if it has to, so there is no need to shorten labels or set a width to fit them.
|
|
34
35
|
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode. That provider must not clip or stack its content: wrap the app root, and keep a nested provider off elements with `overflow: hidden`, a `transform` or their own `z-index`. It sits on `zIndex` `popover`, below the trigger by default, and flips when it would overflow the viewport.
|
|
35
36
|
- Never add key handlers or `tabIndex`; Base UI handles the keyboard.
|
|
36
37
|
- The module has no hooks, so a server component can render it; `onValueChange` must come from a client component.
|
|
@@ -100,6 +101,7 @@ A form field for picking any number of values from a list too long to show at on
|
|
|
100
101
|
- A closed list stays on the page while it fades out, but is `inert` and `aria-hidden` from the moment it closes, so a list opened during the fade (the next filter's) is the only one a screen reader or a role query finds, and nothing in the fading one takes focus or a click (ADR 0113).
|
|
101
102
|
- Selection is a check mark on the option as well as its highlight, so it is not color alone. The check sits at the end of the row; its space is always kept, so the labels start at the option's padding and never shift.
|
|
102
103
|
- The trigger summary is text: the joined labels, or the count. When the count replaces the labels, the labels are hidden from assistive technology so the count is read once.
|
|
104
|
+
- Invalid adds a 2px danger border on the trigger, a 2px `CanvasText` border under forced colors, and the error message with its icon, never colour alone. While the focus ring shows, it replaces the border's second pixel.
|
|
103
105
|
- The shared focus ring shows on the trigger and, from the keyboard, on the highlighted option, drawn inset so the popup's edge does not crowd or clip it (ADR 0122). Under forced colors the pointer's highlighted option is `Highlight` with `HighlightText`; a keyboard-focused one keeps `Canvas` so the `Highlight` ring shows, and the popup keeps its border.
|
|
104
106
|
|
|
105
107
|
## Props
|
package/dist/docs/NavList.md
CHANGED
|
@@ -30,10 +30,10 @@ A column of links to an app's pages, with the current page marked: a sidebar's o
|
|
|
30
30
|
- Inside a `Sidebar` rail (`collapsed`), group headings, labels and counts are visually hidden, an `action` is gone, and each item is a 40px square around its icon or avatar, centered. Their text stays in the accessible names. Every item in a rail needs an icon or an avatar. In a SidebarLayout stacked below 48em a collapsed Sidebar is no rail: the items show open (ADR 0156). In the rail, hover or keyboard focus on an item shows its label and count in a tooltip past its inline end (right, or left right to left); Esc, blur and pointer leave close it, and the pointer can move onto it. Items in one NavList share the tooltip delay: once one has opened, the next opens at once. Outside a rail no tooltip shows (ADR 0159). The tooltip repeats the item's children, so keep them to text and a count: content with an `id` would repeat it.
|
|
31
31
|
- `count` is a trailing subtle `Badge` at `xs`. It is part of the link's accessible name, read after the label, so a bare number says nothing ("Issues 12"). Give it its meaning with `VisuallyHidden`: `count={<>12<VisuallyHidden> open issues</VisuallyHidden></>}`. A nullish or empty count renders nothing.
|
|
32
32
|
- `live` marks a page with something running behind it now (a job, a session, a sync): a 6px `success` dot with a soft halo before the count, or at the end of the row with no count. It is read after the label as `liveLabel`, "live" by default; give it the app's meaning (`liveLabel="session running"`) or its language. In the rail the inline dot hides and a dot sits on the icon's or avatar's top inline-end corner, ringed in `bgPanel`; the rail tooltip shows no dot. `count` is separate and unchanged.
|
|
33
|
-
- `action` takes one control for the row, rendered after the link inside the `li`, never inside it: pass a `Menu` whose `Menu.Trigger` is the icon trigger at `size="sm"` (`icon={EllipsisIcon}`, a 24px target) with its `Menu.Popup`. NavList names nothing, so name each trigger for its row: `label="Actions for jonmilner/ui"`, not a "More actions" repeated down the list. It sits at the row's inline end, `
|
|
33
|
+
- `action` takes one control for the row, rendered after the link inside the `li`, never inside it: pass a `Menu` whose `Menu.Trigger` is the icon trigger at `size="sm"` (`icon={EllipsisIcon}`, a 24px target) with its `Menu.Popup`. NavList names nothing, so name each trigger for its row: `label="Actions for jonmilner/ui"`, not a "More actions" repeated down the list. It sits at the row's inline end, `4` in from the edge, as far from the side as from the top, in the count's place: at rest it is transparent and the count shows; on hover over the row (where hover is real), focus inside the row, or while its menu is open, the action shows and the count goes transparent. Where there is no hover (`(hover: none), (pointer: coarse)`) it always shows, so on a phone or tablet that row's count is never in sight; the count stays in the link's name, but a count the user must see belongs in the label or on a row without an action. The slot holds one node at the inline end: put several actions in the one menu, never a second control or a leading one. A long label wraps before the action and never runs under it. An item with no action renders as before; `null`, `undefined`, a boolean or `""` is none, so `canEdit && <Menu>…` works; a number is not (`items.length && <Menu>…` renders `0` as the action), so make the condition a boolean.
|
|
34
34
|
- A collapsed `Sidebar`'s rail drops the action: it is `display: none` there, out of sight and the tab order, and the row stays the 40px square. Give the rail those actions another way (a menu on the selected page, the page's own header). In a SidebarLayout stacked below 48em the items show open and the action with them.
|
|
35
35
|
- Labels wrap onto a second line in a narrow column, breaking a long word if they must; they never truncate.
|
|
36
|
-
- Items are `sm` text in `fg`, with `6` block and `8` inline padding
|
|
36
|
+
- Items are `sm` text in `fg`, with `6` block and `8` inline padding (`6` at the inline start with an `avatar`), a `med` radius and at least the `sm` (32px) block size, as default style props; the consumer's win, except in the rail. A boxed element at either end of a row is inset as far from the side as from the top and bottom: a 20px avatar `6`, a 24px action `4`. An icon or no glyph keeps the link's `8`. A count keeps the link's `8` end padding like the label, with or without an action, since only boxed elements follow the rule. The `action` slot's direct child takes an `xs` radius inside the row, whatever its own and over a `borderRadius` prop, so its corners nest in the row's `med` (ADR 0178): pass the control itself, not a wrapper around it. The rail's 40px squares keep even padding and an `xs` radius, over `paddingInline` and `borderRadius` props. Hover tints a non-current item where hover is real (`(hover: hover)`).
|
|
37
37
|
- A server component can render the whole list, router `Link` included. `NavList` and `NavList.Group` have no hooks; each `NavList.Item` renders its link inside a client part, the rail tooltip (ADR 0159).
|
|
38
38
|
|
|
39
39
|
## Do
|
package/dist/docs/NumberField.md
CHANGED
|
@@ -71,7 +71,7 @@ A form field for a bounded number: a text input between a decrement button (inli
|
|
|
71
71
|
|
|
72
72
|
- The input is a text box named by its label, announced as a "Number field" (`aria-roledescription`), with a numeric keypad on touch devices. On iOS Base UI asks for the decimal pad when `min` is 0 or more, and the full keyboard otherwise, since neither iOS pad has a minus key. Base UI does not give it the `spinbutton` role (ADR 0161); the arrow keys still step it.
|
|
73
73
|
- The buttons are named "Decrease" and "Increase", are out of the tab order (the arrow keys do their job) and keep focus in the input when pressed. At a bound the button is `aria-disabled` and takes IconButton's disabled look, a dashed border on a muted fill, so the state is not colour alone.
|
|
74
|
-
- Every size is at least 24 px tall, and at `sm` each button is a 24 px square target. Invalid adds a danger border and the error message with its icon, never colour alone; disabled adds a dashed border. Under forced colors the border, text, buttons and disabled state use system colors. On a coarse pointer the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
74
|
+
- Every size is at least 24 px tall, and at `sm` each button is a 24 px square target. Invalid adds a 2px danger border, a 2px `CanvasText` border under forced colors, and the error message with its icon, never colour alone; disabled adds a dashed border. Under forced colors the border, text, buttons and disabled state use system colors. On a coarse pointer the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
75
75
|
|
|
76
76
|
## Props
|
|
77
77
|
|