@jonmilner/ui 0.25.2 → 0.25.4

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 (85) hide show
  1. package/THIRD_PARTY_NOTICES.md +1 -1
  2. package/dist/Alert/Alert.css +1 -1
  3. package/dist/Avatar/Avatar.css +1 -1
  4. package/dist/Badge/Badge.css +1 -1
  5. package/dist/Box/Box.css +1 -1
  6. package/dist/Button/Button.css +1 -1
  7. package/dist/Checkbox/Checkbox.css +1 -1
  8. package/dist/Chip/Chip.css +1 -1
  9. package/dist/Clickable/Clickable.css +1 -1
  10. package/dist/ClickableBox/ClickableBox.css +1 -1
  11. package/dist/Code/Code.css +1 -1
  12. package/dist/ColorField/ColorField.css +1 -1
  13. package/dist/Combobox/Combobox.css +1 -1
  14. package/dist/Dialog/Dialog.css +1 -1
  15. package/dist/Dialog/client.d.mts +1 -1
  16. package/dist/Dialog/client.mjs +32 -51
  17. package/dist/Drawer/Drawer.css +2 -0
  18. package/dist/Drawer/Drawer.css.mjs +7 -0
  19. package/dist/Drawer/client.d.mts +12 -0
  20. package/dist/Drawer/client.mjs +96 -0
  21. package/dist/Drawer/index.d.mts +27 -0
  22. package/dist/Drawer/index.mjs +118 -0
  23. package/dist/Field/Field.css +1 -1
  24. package/dist/Heading/Heading.css +1 -1
  25. package/dist/Icon/Icon.css +1 -1
  26. package/dist/IconButton/IconButton.css +1 -1
  27. package/dist/Inline/Inline.css +1 -1
  28. package/dist/Link/Link.css +1 -1
  29. package/dist/Markdown/Markdown.css +1 -1
  30. package/dist/Menu/Menu.css +1 -1
  31. package/dist/MultiSelect/MultiSelect.css +1 -1
  32. package/dist/NavList/NavList.css +1 -1
  33. package/dist/NavList/index.d.mts +2 -9
  34. package/dist/NumberField/NumberField.css +1 -1
  35. package/dist/Popover/Popover.css +1 -1
  36. package/dist/ProgressBar/ProgressBar.css +2 -0
  37. package/dist/ProgressBar/ProgressBar.css.mjs +7 -0
  38. package/dist/ProgressBar/index.d.mts +10 -0
  39. package/dist/ProgressBar/index.mjs +32 -0
  40. package/dist/RadioGroup/RadioGroup.css +1 -1
  41. package/dist/SearchField/SearchField.css +1 -1
  42. package/dist/Select/Select.css +1 -1
  43. package/dist/Sidebar/Sidebar.css +1 -1
  44. package/dist/Sidebar/index.d.mts +2 -9
  45. package/dist/SidebarLayout/SidebarLayout.css +1 -1
  46. package/dist/Stack/Stack.css +1 -1
  47. package/dist/Switch/Switch.css +1 -1
  48. package/dist/TabBar/TabBar.css +2 -0
  49. package/dist/TabBar/TabBar.css.mjs +7 -0
  50. package/dist/TabBar/index.d.mts +25 -0
  51. package/dist/TabBar/index.mjs +61 -0
  52. package/dist/Table/Table.css +1 -1
  53. package/dist/Tabs/Tabs.css +1 -1
  54. package/dist/Tag/Tag.css +1 -1
  55. package/dist/Text/Text.css +1 -1
  56. package/dist/TextField/TextField.css +1 -1
  57. package/dist/Textarea/Textarea.css +1 -1
  58. package/dist/Toast/Toast.css +1 -1
  59. package/dist/Tooltip/Tooltip.css +1 -1
  60. package/dist/VisuallyHidden/VisuallyHidden.css +1 -1
  61. package/dist/base.css +1 -1
  62. package/dist/docs/Code.md +2 -2
  63. package/dist/docs/Dialog.md +1 -0
  64. package/dist/docs/Drawer.md +156 -0
  65. package/dist/docs/NavList.md +3 -2
  66. package/dist/docs/ProgressBar.md +81 -0
  67. package/dist/docs/Sidebar.md +3 -2
  68. package/dist/docs/TabBar.md +135 -0
  69. package/dist/docs/Table.md +2 -2
  70. package/dist/docs/Tabs.md +1 -1
  71. package/dist/docs/llms.txt +3 -0
  72. package/dist/docs/manifest.json +273 -9
  73. package/dist/index.d.mts +7 -3
  74. package/dist/index.mjs +38 -35
  75. package/dist/popup/client.mjs +1 -1
  76. package/dist/popup/modal-frame.d.mts +3 -0
  77. package/dist/popup/modal-frame.mjs +30 -0
  78. package/dist/scroll-region/scroll-region.d.mts +2 -9
  79. package/dist/styles/atoms.css +1 -1
  80. package/dist/styles/layers.css +1 -1
  81. package/dist/styles/responsive.css +1 -1
  82. package/dist/styles/scroll-region.css +1 -1
  83. package/dist/styles/status-message.css +1 -1
  84. package/dist/types.d.mts +10 -1
  85. package/package.json +15 -3
@@ -0,0 +1,156 @@
1
+ # Drawer
2
+
3
+ ## Purpose
4
+
5
+ A modal panel that slides up from the bottom edge, for a short task or a few actions tied to the page behind it, without leaving that page, on a touch screen. Built on Base UI's Drawer, which owns the behavior: focus moves into the panel and stays there, the page behind is hidden from assistive tech and does not scroll, and Esc, a press on the backdrop, the close button and a downward swipe all close it, with focus back on the trigger. The parts add the look: a dimmed backdrop, a panel with a drag handle, a title and a close button, and a slide that is a plain fade under reduced motion.
6
+
7
+ ## When to use
8
+
9
+ - A short task or a few actions about one thing on the page, on a phone: an item's options, a "New" menu with a line of help per choice, a small form.
10
+ - The content is a title, an optional line of description, then a short list of actions or a small form.
11
+
12
+ ## When not to use
13
+
14
+ - A confirmation, or a form that stands on its own, or any modal on a wide screen: use `Dialog`, which is centred.
15
+ - Content beside the page that should not block it: use `Popover`, which is non-modal and anchored to its trigger.
16
+ - A list of commands anchored to a button: use `Menu`.
17
+ - Confirming something destructive or irreversible: use `AlertDialog`, which focuses Cancel and ignores outside presses.
18
+ - A long flow or a lot of content: give it a page.
19
+
20
+ ## Rules
21
+
22
+ - Compose the parts: `Drawer` > `Drawer.Trigger` + `Drawer.Popup` > `Drawer.Body` + `Drawer.Actions` > `Drawer.Close`. `Drawer` holds the open state and renders no element, so it takes no `className` or `style`; every other part does, plus style props.
23
+ - `Drawer.Popup` takes a required `title` and an optional `description`. They head the panel as an `h2` and muted text beside a close `IconButton`, and name and describe the drawer for screen readers. Keep the title short: the item or task it is about ("Double cream", "New recipe").
24
+ - `closeLabel` names the close button; it is "Close" by default. Pass the app's own word when it is not in English.
25
+ - The panel spans the viewport's width, its top corners rounded at the dialog radius (`lg`). It is as tall as its content, up to the viewport less a strip of backdrop at the top; taller content scrolls inside it. Its bottom padding adds `env(safe-area-inset-bottom)`, so the last row clears a phone's home indicator; for that, the app's viewport meta needs `viewport-fit=cover`. A `padding`, `paddingBlock` or `paddingBlockEnd` replaces that bottom pad.
26
+ - It opens from the bottom edge only. There is no `side` prop, and no snap points.
27
+ - Put the content in `Drawer.Body`, or a list of actions straight in the popup. `Drawer.Actions` end-aligns buttons and wraps them, as `Dialog.Actions` does.
28
+ - `Drawer.Trigger` and `Drawer.Close` are bare `Clickable`s, as on `Dialog`. Pass Button's `variant`, `size`, `iconStart`, `iconEnd` or `uppercase` for a button look. Without them, style them with style props and give them an accessible name.
29
+ - `disabled` on the trigger keeps it focusable and announced, and stops it opening.
30
+ - Control it with `open` and `onOpenChange` to close it after an action or keep it open on an error. `onOpenChangeComplete` runs once the exit transition ends.
31
+ - The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode, on `zIndex` `modal`. That provider must not clip or stack its content, as for `Dialog`. A drawer opened only through `open`, with no `Drawer.Trigger`, portals to `<body>`.
32
+ - It is always modal. Never add key handlers, `tabIndex`, a focus trap or your own swipe handling to the parts.
33
+ - Focus opens on the close button, as in Dialog; `initialFocus` on `Drawer.Popup` sends it elsewhere. `finalFocus` sends focus elsewhere on close, as on `Dialog.Popup` (ADR 0192).
34
+ - The module has no hooks, so a server component can render the parts; `onOpenChange` and other functions must come from a client component.
35
+
36
+ ## Do
37
+
38
+ ```tsx
39
+ <Drawer>
40
+ <Drawer.Trigger variant="secondary">Double cream</Drawer.Trigger>
41
+ <Drawer.Popup title="Double cream" description="On hand · used in 3 of your recipes">
42
+ <Drawer.Body>
43
+ <Button variant="ghost" onClick={runningLow}>
44
+ Running low
45
+ </Button>
46
+ <Button variant="ghost" onClick={ranOut}>
47
+ Ran out
48
+ </Button>
49
+ </Drawer.Body>
50
+ </Drawer.Popup>
51
+ </Drawer>
52
+ ```
53
+
54
+ ```tsx
55
+ // Closes once the action succeeds; stays open on an error.
56
+ const [open, setOpen] = useState(false);
57
+ <Drawer open={open} onOpenChange={setOpen}>
58
+ <Drawer.Trigger variant="primary">New recipe</Drawer.Trigger>
59
+ <Drawer.Popup title="New recipe">…</Drawer.Popup>
60
+ </Drawer>;
61
+ ```
62
+
63
+ ## Don't
64
+
65
+ ```tsx
66
+ // A heading in the body instead of `title`: the drawer has no name.
67
+ <Drawer.Popup title="">
68
+ <Heading>Double cream</Heading>
69
+ </Drawer.Popup>
70
+ ```
71
+
72
+ ```tsx
73
+ // A long form in a drawer on a wide screen: use a Dialog there, or a page.
74
+ <Drawer.Popup title="Edit recipe">
75
+ <RecipeForm />
76
+ </Drawer.Popup>
77
+ ```
78
+
79
+ ## Accessibility
80
+
81
+ - 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.
82
+ - Opening moves focus into the popup; Tab and Shift+Tab cycle inside it, and the page behind is `aria-hidden`. Esc, a backdrop press, the close button or a downward swipe closes it, and focus returns to the trigger.
83
+ - A closed drawer stays on the page while it slides out, but is `inert` and `aria-hidden` from the moment it closes, and focus is back on the trigger at once (ADR 0113).
84
+ - The drag handle is decorative and `aria-hidden`; the close button, an `IconButton` named by `closeLabel`, is the way out for a pointer or a keyboard, and a screen reader's dismiss gesture or Esc for the rest.
85
+ - The panel takes the shared focus ring when focused from the keyboard. Under forced colors it keeps a border on its top and sides, and the handle is `CanvasText`.
86
+ - With `prefers-reduced-motion`, it fades in and out where it rests instead of sliding.
87
+ - The backdrop is Dialog's: the `backdrop` color role over the page, and no fill under forced colors. It clears as a swipe drags the panel away.
88
+
89
+ ## Theming
90
+
91
+ The backdrop reads the same `backdrop` color role as `Dialog`; set it as `Dialog.docs.md` shows.
92
+
93
+ ## Props
94
+
95
+ Generated from the TypeScript types.
96
+
97
+ ### Drawer
98
+
99
+ | Prop | Type | Required | Description |
100
+ | --- | --- | --- | --- |
101
+ | `children` | `ReactNode` | no | |
102
+ | `defaultOpen` | `boolean` | no | Whether the drawer is initially open. To render a controlled drawer, use the `open` prop instead. |
103
+ | `onOpenChange` | `((open: boolean, eventDetails: DrawerRootChangeEventDetails) => void)` | no | Event handler called when the drawer is opened or closed. |
104
+ | `onOpenChangeComplete` | `((open: boolean) => void)` | no | Event handler called after any animations complete when the drawer is opened or closed. |
105
+ | `open` | `boolean` | no | Whether the drawer is currently open. |
106
+
107
+ ### Drawer.Actions
108
+
109
+ No props of its own.
110
+
111
+ Also accepts the style props (see `manifest.json` `styleProps`).
112
+
113
+ ### Drawer.Body
114
+
115
+ No props of its own.
116
+
117
+ Also accepts the style props (see `manifest.json` `styleProps`).
118
+
119
+ ### Drawer.Close
120
+
121
+ | Prop | Type | Required | Description |
122
+ | --- | --- | --- | --- |
123
+ | `iconEnd` | `ComponentType` | no | |
124
+ | `iconStart` | `ComponentType` | no | |
125
+ | `size` | `"lg" \| "med" \| "sm"` | no | |
126
+ | `uppercase` | `boolean` | no | |
127
+ | `variant` | `"ghost" \| "primary" \| "secondary"` | no | |
128
+
129
+ Also accepts the style props (see `manifest.json` `styleProps`).
130
+
131
+ ### Drawer.Popup
132
+
133
+ | Prop | Type | Required | Description |
134
+ | --- | --- | --- | --- |
135
+ | `closeLabel` | `string` | no | |
136
+ | `description` | `ReactNode` | no | |
137
+ | `finalFocus` | `boolean \| RefObject<HTMLElement \| null> \| ((closeType: InteractionType) => void \| boolean \| HTMLElement \| null)` | no | Determines the element to focus when the drawer is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
138
+ | `initialFocus` | `boolean \| RefObject<HTMLElement \| null> \| ((openType: InteractionType) => void \| boolean \| HTMLElement \| null)` | no | Determines the element to focus when the drawer is opened. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
139
+ | `title` | `string \| number \| bigint \| Iterable<ReactNode> \| Promise<AwaitedReactNode> \| ReactElement<unknown, string \| JSXElementConstructor<any>> \| ReactPortal` | yes | |
140
+
141
+ Also accepts the style props (see `manifest.json` `styleProps`).
142
+
143
+ ### Drawer.Trigger
144
+
145
+ | Prop | Type | Required | Description |
146
+ | --- | --- | --- | --- |
147
+ | `handle` | `DrawerHandle<unknown>` | no | A handle to associate the trigger with a drawer. Can be created with the Drawer.createHandle() method. |
148
+ | `iconEnd` | `ComponentType` | no | |
149
+ | `iconStart` | `ComponentType` | no | |
150
+ | `id` | `string` | no | ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for drawers in controlled mode (with the Drawer.Root `triggerId` prop). |
151
+ | `payload` | `unknown` | no | A payload to pass to the drawer when it is opened. |
152
+ | `size` | `"lg" \| "med" \| "sm"` | no | |
153
+ | `uppercase` | `boolean` | no | |
154
+ | `variant` | `"ghost" \| "primary" \| "secondary"` | no | |
155
+
156
+ Also accepts the style props (see `manifest.json` `styleProps`).
@@ -14,6 +14,7 @@ A column of links to an app's pages, with the current page marked: a sidebar's o
14
14
  ## When not to use
15
15
 
16
16
  - Switching views that share one page and keep the URL: use `Tabs`.
17
+ - An app's three to five top-level sections along the bottom of a phone screen, icon above label: use `TabBar`.
17
18
  - An item that runs an action or command, such as Sign out or New project: use `Menu` or `Button`. The link itself only navigates. An action that belongs to one row, such as Rename or Delete for that row's page, goes beside the link in `action` (ADR 0169).
18
19
  - Links in running text, or one link on its own: use a link (`Clickable as="a"`).
19
20
  - A tree of collapsible or nested groups, or a drawer that slides in on a phone: not supported. One level of groups, always open.
@@ -177,8 +178,8 @@ Generated from the TypeScript types.
177
178
 
178
179
  | Prop | Type | Required | Description |
179
180
  | --- | --- | --- | --- |
180
- | `aria-label` | `string` | no | Defines a string value that labels the current element. |
181
- | `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. |
181
+ | `aria-label` | `string` | no | Defines a string value that labels the current element. The element's name. Required unless `aria-labelledby` names it. |
182
+ | `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. The id of the element that names this one. Required unless `aria-label` names it. |
182
183
 
183
184
  Also accepts the style props (see `manifest.json` `styleProps`).
184
185
 
@@ -0,0 +1,81 @@
1
+ # ProgressBar
2
+
3
+ ## Purpose
4
+
5
+ Shows how far along a task with a known end is: a thin bar whose filled part is `value / max` of its width. A 4px `controlFill` track with an `accent` indicator, built on Base UI's `Progress`, with `role="progressbar"`. It is not interactive and holds no text; the visible count, if any, is the caller's text beside it.
6
+
7
+ ## When to use
8
+
9
+ - A run through a known number of items: "6 of 14" imports reviewed, steps of a setup.
10
+ - A task whose share done is known and changes as it goes: an upload, a sync with a known total.
11
+
12
+ ## When not to use
13
+
14
+ - How many of something there are (unread, open issues): use a count `Badge`. A badge says how many; this shows how far.
15
+ - Work whose end is unknown: an indeterminate bar is out of scope; show a busy control (`Button`'s `loading`) or a status message.
16
+ - A value the user sets: use `NumberField` or a slider, not a bar to look at.
17
+ - A measurement within a known range that is not progress (disk use, a score): that is a meter, not a progress bar.
18
+ - Text inside the bar, or a circle: neither is supported. Put the count beside the bar in `Text`.
19
+
20
+ ## Rules
21
+
22
+ - `value` is how much is done and `max` the amount in all (100 by default, so a bare `value` is a percentage). Values below 0 show 0 and values above `max` show `max`; `aria-valuenow` is the clamped value. A `NaN` value shows 0. A `max` that is not above 0 or not finite (`NaN` while a total loads, 0 for no work) shows an empty bar out of 100.
23
+ - Name it with `aria-label` ("Imports reviewed"), or with `aria-labelledby` when a visible heading or label already names the work. One of the two, never both; the type requires one.
24
+ - The bar is a block, as wide as its parent. In a flex row give it a width or `flexGrow={1}`.
25
+ - The visible count is the caller's: a `Text` beside the bar ("6 of 14"). Screen readers hear the share as a percentage by default; when you show a count, pass the same words as `aria-valuetext` so both say one thing.
26
+ - Fill and radius are default style props on the track (`backgroundColor="controlFill"`, `borderRadius="full"`, the 2px corner on a 4px bar); a consumer's win. The indicator is always `accent`, with the track's corners. The height is always 4px, so the block-size style props are off the type. `className`, `style`, `ref` and other `div` props go to the track, `className` last.
27
+ - The bar does not animate between values: each value shows at once.
28
+ - The module has no hooks, so a server component can render it.
29
+
30
+ ## Do
31
+
32
+ ```tsx
33
+ <Stack gap="8">
34
+ <Inline justifyContent="space-between" gap="12">
35
+ <Heading as="h1">Review imports</Heading>
36
+ <Label>6 of 14</Label>
37
+ </Inline>
38
+ <ProgressBar aria-label="Imports reviewed" aria-valuetext="6 of 14" max={14} value={6} />
39
+ </Stack>
40
+ ```
41
+
42
+ ```tsx
43
+ // A percentage: max is 100 by default.
44
+ <ProgressBar aria-label="Upload" value={40} />
45
+ ```
46
+
47
+ ## Don't
48
+
49
+ ```tsx
50
+ // No name: a screen reader hears an unnamed progress bar.
51
+ <ProgressBar max={14} value={6} />
52
+ ```
53
+
54
+ ```tsx
55
+ // The count goes beside the bar, not in it; the bar takes no children.
56
+ <ProgressBar aria-label="Imports reviewed" max={14} value={6}>
57
+ 6 of 14
58
+ </ProgressBar>
59
+ ```
60
+
61
+ ## Accessibility
62
+
63
+ - A `div` with `role="progressbar"`, `aria-valuemin="0"`, `aria-valuemax` set to `max`, `aria-valuenow` set to the clamped value, and its name from `aria-label` or `aria-labelledby`. `aria-valuetext` is the share as a percentage unless you pass your own.
64
+ - It is not focusable and not a live region: a screen reader reads it when it reaches it. If reaching the end matters right away, announce it elsewhere (a toast).
65
+ - The indicator is `accent` on `controlFill`, and the share done is its length, not its color.
66
+ - Under forced colors the track is `Canvas` inside a 1px `CanvasText` outline and the indicator is `CanvasText`, so the bar and the share done both show in any theme.
67
+
68
+ ## Props
69
+
70
+ Generated from the TypeScript types.
71
+
72
+ ### ProgressBar
73
+
74
+ | Prop | Type | Required | Description |
75
+ | --- | --- | --- | --- |
76
+ | `aria-label` | `string` | no | The element's name. Required unless `aria-labelledby` names it. |
77
+ | `aria-labelledby` | `string` | no | The id of the element that names this one. Required unless `aria-label` names it. |
78
+ | `max` | `number` | no | |
79
+ | `value` | `number` | yes | |
80
+
81
+ Also accepts the style props (see `manifest.json` `styleProps`).
@@ -13,6 +13,7 @@ An app's sidebar: a named `aside` on the `bgPanel` surface, with a header row, t
13
13
 
14
14
  - A sidebar that never collapses and needs no surface or footer: `SidebarLayout.Sidebar` alone, with a `NavList` in it.
15
15
  - A drawer that slides over the page on a phone: not supported. Below 48em of the layout's width the sidebar stacks above the page, full width.
16
+ - An app's three to five top-level sections on a phone: use `TabBar` along the bottom of the screen; the app's layout shows it in place of the sidebar there.
16
17
  - Secondary content beside the page (filters, an outline): `SidebarLayout.Sidebar as="aside"`.
17
18
 
18
19
  ## Rules
@@ -94,8 +95,8 @@ Generated from the TypeScript types.
94
95
 
95
96
  | Prop | Type | Required | Description |
96
97
  | --- | --- | --- | --- |
97
- | `aria-label` | `string` | no | Defines a string value that labels the current element. |
98
- | `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. |
98
+ | `aria-label` | `string` | no | Defines a string value that labels the current element. The element's name. Required unless `aria-labelledby` names it. |
99
+ | `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. The id of the element that names this one. Required unless `aria-label` names it. |
99
100
  | `collapsed` | `boolean` | no | |
100
101
  | `footer` | `ReactNode` | no | |
101
102
  | `header` | `ReactNode` | no | |
@@ -0,0 +1,135 @@
1
+ # TabBar
2
+
3
+ ## Purpose
4
+
5
+ A bar along the bottom of a phone screen that moves between an app's three to five top-level sections. The parts are `TabBar` (a named `nav` around a list) and `TabBar.Item` (one link: an icon above a one- or two-word label, with an optional count beside the icon). The items share the bar's width equally. Items are links inside a `nav` landmark, not ARIA tabs: an `<a>` by default, or a router's `Link` through `as`, which keeps the router's props typed. The app says which item is current; TabBar reads nothing from the URL (ADR 0205).
6
+
7
+ ## When to use
8
+
9
+ - A phone-first app's top-level sections, always one tap away at the bottom of the screen: Recipes, Plan, Shopping, On hand.
10
+ - Three to five sections of equal weight, each its own route, each with an icon and a short label.
11
+ - A section with a count worth seeing from anywhere (items left to buy, unread messages): `count` beside its icon.
12
+
13
+ ## When not to use
14
+
15
+ - The same links on a wide screen, or more than five of them: use `NavList`, in a `Sidebar` when they run down the side of the page. An app that shows a TabBar on a phone and a Sidebar on a wide screen renders both and hides one in its own layout; TabBar does not hide itself.
16
+ - Switching panels inside one page that keep the URL: use `Tabs`. TabBar's items change the page.
17
+ - An action or command, such as New recipe or Sign out: use `Button`, `IconButton` or `Menu`. An item only navigates.
18
+ - Fixing the bar to the viewport: the app's layout does that (`position: fixed` or a sticky footer row). TabBar is a plain block that sits where it is rendered.
19
+
20
+ ## Rules
21
+
22
+ - `TabBar` needs a name, and its type requires one: `aria-label` ("Sections", "Main") or `aria-labelledby`. A page with another `nav` tells them apart by these names. Its props land on the `nav`.
23
+ - Children are three to five `TabBar.Item`s. The bar puts them in one row of equal columns, whatever their labels; more than five is not supported.
24
+ - `TabBar.Item` is an `<a>` by default: pass `href`. With `as={Link}`, it takes the router's props instead (`to`, `prefetch`) and its type checks them. Every other prop, `ref` and the style props included, lands on the link; the `li` around it takes none. Use the router's plain `Link`, not a `NavLink` that sets `aria-current` itself.
25
+ - `icon` is required: an icon component (`icon={InboxIcon}`), drawn at `xl` (20px) above the label and hidden from assistive tech, since the label names the link.
26
+ - The label is the item's children: a word or two of text, `xs` and medium. It stays on one line; a label too long for its column ends in an ellipsis, and the link's name keeps the full text.
27
+ - `current` marks the link to the section on screen: `aria-current="page"`, the `accent` colour, a semibold label, and a 2px `accent` line, 32px wide, on the bar's top edge above the item. Set it on one item at most. It is the only way to set `aria-current`: the type omits the raw attribute.
28
+ - `count` is a subtle `Badge` at `xs` beside the icon, at its inline-end top corner; the icon stays centred. It is part of the link's accessible name, read after the label, so a bare number says nothing ("Shopping 6"). Give it its meaning with `VisuallyHidden`: `count={<>6<VisuallyHidden> left to buy</VisuallyHidden></>}`. A nullish, boolean or empty count renders nothing, but a `0` or a fragment around one does not: guard it (`left > 0 && <>…</>`) to hide a zero. Keep it short: two or three characters.
29
+ - The bar is `bg` with one `border` separator along its top, `8` of inline padding, and `env(safe-area-inset-bottom)` of padding below the items (at least `4`, so a focus ring stays inside the bar), so they clear a phone's home indicator. That inset is 0 unless the page's viewport meta has `viewport-fit=cover`. The background and inline padding are default style props, so the consumer's win; the separator and the bottom inset are the component's CSS.
30
+ - Items are at least 56px (`xl`) high, `fgMuted` with `4` of inline padding and a `med` radius, as default style props; the consumer's win. Hover turns a non-current item `fg` where hover is real (`(hover: hover)`).
31
+ - A server component can render the whole bar, router `Link` included: no part has hooks.
32
+
33
+ ## Do
34
+
35
+ ```tsx
36
+ <TabBar aria-label="Sections">
37
+ <TabBar.Item href="/recipes" icon={BookIcon}>
38
+ Recipes
39
+ </TabBar.Item>
40
+ <TabBar.Item href="/plan" icon={ClipboardIcon}>
41
+ Plan
42
+ </TabBar.Item>
43
+ <TabBar.Item
44
+ count={
45
+ <>
46
+ 6<VisuallyHidden> left to buy</VisuallyHidden>
47
+ </>
48
+ }
49
+ current
50
+ href="/shopping"
51
+ icon={ShoppingCartIcon}
52
+ >
53
+ Shopping
54
+ </TabBar.Item>
55
+ <TabBar.Item href="/on-hand" icon={RefrigeratorIcon}>
56
+ On hand
57
+ </TabBar.Item>
58
+ </TabBar>
59
+ ```
60
+
61
+ ```tsx
62
+ // A router's link: its props stay typed. The router says which item is current. The app's layout
63
+ // fixes the bar to the bottom of the screen.
64
+ <TabBar aria-label="Sections" className={layout.bottomBar}>
65
+ {sections.map((section) => (
66
+ <TabBar.Item
67
+ as={Link}
68
+ current={pathname.startsWith(section.to)}
69
+ icon={section.icon}
70
+ key={section.to}
71
+ to={section.to}
72
+ >
73
+ {section.label}
74
+ </TabBar.Item>
75
+ ))}
76
+ </TabBar>
77
+ ```
78
+
79
+ ## Don't
80
+
81
+ ```tsx
82
+ // No name: another nav on the page could not be told apart. The type rejects it.
83
+ <TabBar>
84
+ <TabBar.Item href="/" icon={InboxIcon}>
85
+ Inbox
86
+ </TabBar.Item>
87
+ </TabBar>
88
+ ```
89
+
90
+ ```tsx
91
+ // A sentence for a label: it cannot fit a fifth of a phone's width, so it is cut short.
92
+ <TabBar.Item href="/shopping" icon={ShoppingCartIcon}>
93
+ Your shopping list for this week
94
+ </TabBar.Item>
95
+ ```
96
+
97
+ ```tsx
98
+ // A button that runs an action: a TabBar item navigates. Put the action in the page.
99
+ <TabBar.Item as="button" icon={PlusIcon} onClick={addRecipe}>
100
+ Add
101
+ </TabBar.Item>
102
+ ```
103
+
104
+ ## Accessibility
105
+
106
+ - A `nav` landmark named by its `aria-label` or `aria-labelledby`, around a native list: screen readers announce the landmark and the number of links, and their landmark commands reach it (WAI-ARIA landmarks). These are links, not ARIA tabs: no `tablist` role and no arrow-key model, since each item loads a page.
107
+ - The current item has `aria-current="page"`, announced as "current page". Its line and semibold label show it without colour alone (WCAG 1.4.1). Under forced colours the line is `Highlight`.
108
+ - Label text is `fgMuted`, and the current item's `accent`, on the bar's `bg`: both are checked 4.5:1 pairs in light and dark (ADR 0031).
109
+ - The icon is hidden; the label and the count, with its meaning, make the link's name. A truncated label keeps its full text in the name.
110
+ - Links are in the tab order in reading order and show the shared focus ring. Every item is at least 56px high and a quarter to a fifth of the bar wide, past the 24px floor (WCAG 2.5.8, ADR 0124) and the 44px touch guideline.
111
+
112
+ ## Props
113
+
114
+ Generated from the TypeScript types.
115
+
116
+ ### TabBar
117
+
118
+ | Prop | Type | Required | Description |
119
+ | --- | --- | --- | --- |
120
+ | `aria-label` | `string` | no | Defines a string value that labels the current element. |
121
+ | `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. |
122
+
123
+ Also accepts the style props (see `manifest.json` `styleProps`).
124
+
125
+ ### TabBar.Item
126
+
127
+ | Prop | Type | Required | Description |
128
+ | --- | --- | --- | --- |
129
+ | `as` | `ElementType` | no | |
130
+ | `children` | `ReactNode` | yes | |
131
+ | `count` | `ReactNode` | no | |
132
+ | `current` | `boolean` | no | |
133
+ | `icon` | `ComponentType` | yes | |
134
+
135
+ Also accepts every `<a>` attribute (change the element with `as`) and the style props (see `manifest.json` `styleProps`).
@@ -254,7 +254,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
254
254
 
255
255
  | Prop | Type | Required | Description |
256
256
  | --- | --- | --- | --- |
257
- | `aria-label` | `string` | no | The region's name. Required unless `aria-labelledby` names it. |
258
- | `aria-labelledby` | `string` | no | The id of the element that names the region. Required unless `aria-label` names it. |
257
+ | `aria-label` | `string` | no | The element's name. Required unless `aria-labelledby` names it. |
258
+ | `aria-labelledby` | `string` | no | The id of the element that names this one. Required unless `aria-label` names it. |
259
259
 
260
260
  Also accepts the style props (see `manifest.json` `styleProps`).
package/dist/docs/Tabs.md CHANGED
@@ -11,7 +11,7 @@ Switches between views that share one place on the page. The parts are `Tabs` (t
11
11
 
12
12
  ## When not to use
13
13
 
14
- - Moving between pages or routes: use `NavList`, or links (`Clickable as="a"`) in a `nav`. Tabs do not change the URL and the panels are not separate pages.
14
+ - Moving between pages or routes: use `NavList`, `TabBar` for an app's top-level sections along the bottom of a phone screen, or links (`Clickable as="a"`) in a `nav`. Tabs do not change the URL and the panels are not separate pages.
15
15
  - A sequence the user must go through in order: use a stepper.
16
16
  - Two or three options that set a value in a form: use `RadioGroup`.
17
17
  - Content that should be readable at once, or compared side by side: show it all, or use sections with headings.
@@ -30,6 +30,7 @@
30
30
  - [ColorField](ColorField.md): A form field for one colour as a `#rrggbb` string: a swatch, the browser's own colour picker (`<input type="color">`), before a hex text input (role `textbox`) that holds the value. Picking a colour writes its hex; typing a valid hex moves the swatch. The hex input has TextField's look, with the swatch over its inline-start padding. Built on Base UI's `Input` and a native colour input, since Base UI has no colour picker (ADR 0003, 0114); it composes `Field` for its label, description and error (ADR 0026). Three sizes at Button's heights (`sm`, `med`, `lg`: 24, 32 and 40 px, ADR 0124); the swatch is 24px, or 32px in `lg`.
31
31
  - [Combobox](Combobox.md): A form field for picking one value, or any number with `multiple`, from a list long enough that the user types to narrow it. A trigger drawn as MultiSelect's opens a popup with a filter input above the options; typing keeps the options whose label holds the query, ignoring case and accents. Each picked option shows a check mark, and the trigger shows the picked label, or with `multiple` the joined labels, then a count ("3 selected") once they would not fit. Built on Base UI's `Combobox` (ADR 0003, 0142), which owns the keyboard and focus: focus moves into the filter as the popup opens and stays there, the arrow keys move the highlight, Enter picks, Esc and an outside click close it, and focus returns to the trigger. It shares MultiSelect's and Select's trigger, popup, option rows and summary (ADR 0134, 0142) and composes `Field` for its label, description and error (ADR 0026).
32
32
  - [Dialog](Dialog.md): 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.
33
+ - [Drawer](Drawer.md): A modal panel that slides up from the bottom edge, for a short task or a few actions tied to the page behind it, without leaving that page, on a touch screen. Built on Base UI's Drawer, which owns the behavior: focus moves into the panel and stays there, the page behind is hidden from assistive tech and does not scroll, and Esc, a press on the backdrop, the close button and a downward swipe all close it, with focus back on the trigger. The parts add the look: a dimmed backdrop, a panel with a drag handle, a title and a close button, and a slide that is a plain fade under reduced motion.
33
34
  - [Field](Field.md): Wires one form control to its label, description and error: ids, `htmlFor`, `aria-describedby` and `aria-invalid`. It is input-agnostic: the control inside is Base UI's `Field.Control` or a Base UI control (Checkbox, Combobox), and Base UI does the wiring. The parts are `Field` (the root, a flex column), `Field.Label`, `Field.Description` and `Field.Error`. Built on Base UI `Field` (ADR 0003, 0026, 0046); `@base-ui/react` is a peer dependency, so the app's Base UI controls and Field share one copy of its contexts.
34
35
  - [Flex](Flex.md): 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">`.
35
36
  - [Heading](Heading.md): Section and page headings. A `Text` with heading defaults: the `heading` font role, `semibold`, `sm` leading, and balanced line wrapping. The level (`as`) and the look (`size`) are separate, so the outline stays right whatever the design calls for.
@@ -44,6 +45,7 @@
44
45
  - [NavList](NavList.md): A column of links to an app's pages, with the current page marked: a sidebar's or a settings page's navigation. The parts are `NavList` (a named `nav` around a list), `NavList.Group` (a heading over a run of items) and `NavList.Item` (one link, with an optional leading icon, live dot and trailing count, and an optional `action` beside the link: a control for that row, such as its ⋯ menu). Items are links, not buttons: an `<a>` by default, or a router's `Link` through `as`, which keeps the router's props typed (ADR 0149). The app says which item is current; NavList reads nothing from the URL.
45
46
  - [NumberField](NumberField.md): A form field for a bounded number: a text input between a decrement button (inline start) and an increment button (inline end), with the number centred between them. Built on Base UI's `NumberField` (ADR 0003, 0161); it composes `Field` for its label, description and error (ADR 0026). Three sizes at Button's heights (`sm`, `med`, `lg`: 24, 32 and 40 px, ADR 0124); the input fills the Field's width.
46
47
  - [Popover](Popover.md): Supplementary content anchored to a control and opened on purpose: a row's details as label and value pairs, a short explanation with a link or a button. It is non-modal, so the page behind stays usable. Built on Base UI's Popover, which owns the behavior: a click, tap, Enter or Space opens it, an outside press or Esc closes it, focus moves in on open and back to the trigger on close. The parts add the look: the raised surface of the other popups, and a zoom-and-fade that is a plain fade under reduced motion.
48
+ - [ProgressBar](ProgressBar.md): Shows how far along a task with a known end is: a thin bar whose filled part is `value / max` of its width. A 4px `controlFill` track with an `accent` indicator, built on Base UI's `Progress`, with `role="progressbar"`. It is not interactive and holds no text; the visible count, if any, is the caller's text beside it.
47
49
  - [RadioGroup](RadioGroup.md): One choice among a few options, all shown at once. A form field built on Base UI `RadioGroup` and `Radio` (ADR 0003, 0046) inside a `Fieldset`: a `radiogroup` named by its legend, with a `radio` per option. Each option is a 24 by 24 CSS px target (WCAG 2.2) with the shared focus ring; the 16px circle inside shows a dot when checked. It composes `Field` for the group's description and error and for each option's label and description (ADR 0026, 0133).
48
50
  - [Run](Run.md): A styled word inside a line of text: bold, a color, a semantic element such as `strong`, `em` or `time`. A `Text` rendered as a `span`, with no size or font, so inside a `Body`, `Heading` or table cell it takes that text's size and font (ADR 0200).
49
51
  - [SearchField](SearchField.md): A form field for a search query: an `<input type="search">` (role `searchbox`) with a search icon at its inline start and, while it holds a value, a clear button at its inline end. Escape empties a field that has a value, and the clear button empties it and puts focus back in the input, so a keyboard user never loses their place (ADR 0087). Built on Base UI's `Input` (ADR 0003); it composes `Field` for its label, description and error (ADR 0026). Three sizes at Button's heights (`sm`, `med`, `lg`: 24, 32 and 40 px, ADR 0124); the clear button is 24px, or 32px in `lg`.
@@ -52,6 +54,7 @@
52
54
  - [SidebarLayout](SidebarLayout.md): A page's navigation or secondary column beside its main content. `SidebarLayout` is a wrapping flex row; `SidebarLayout.Sidebar` keeps a fixed width (`inlineSize="sidebar"`, 15rem) at the inline start and `SidebarLayout.Main` takes the rest. When the layout itself is narrower than 48em, the sidebar stacks above main at full width. It reads its own width through a container query, not the viewport's, so it stacks inside a narrow slot on a wide screen too. When wide, the sidebar is sticky: it stays in view while the page scrolls, capped at the viewport's height, and scrolls on its own when its content is taller. An optional `SidebarLayout.Header` spans the full width above both: wide, it pins to the top of the viewport and the sidebar sticks below it; stacked, it scrolls away with the page. Every part is a `Box` and takes style props, except the few the layout fixes (see Rules).
53
55
  - [Stack](Stack.md): A vertical column of children with even space between them. `Stack` is a `Flex` (a `Box` with `display="flex"`) with `flexDirection="column"` as a default style prop, spaced by a required `gap`. Children render as they are: no wrapper per child.
54
56
  - [Switch](Switch.md): Turns one setting on or off, and the change applies the moment it flips. Built on Base UI `Switch` (ADR 0003, 0137): a `span` with `role="switch"` and `aria-checked`, plus a hidden checkbox input that submits with a form. The span is a 24 px target with the shared focus ring around a pill track: off is an outlined track with the thumb at the start, on a filled `accent` track with the thumb at the end. It composes `Field` for its label, description and error (ADR 0026), with the label after the switch.
57
+ - [TabBar](TabBar.md): A bar along the bottom of a phone screen that moves between an app's three to five top-level sections. The parts are `TabBar` (a named `nav` around a list) and `TabBar.Item` (one link: an icon above a one- or two-word label, with an optional count beside the icon). The items share the bar's width equally. Items are links inside a `nav` landmark, not ARIA tabs: an `<a>` by default, or a router's `Link` through `as`, which keeps the router's props typed. The app says which item is current; TabBar reads nothing from the URL (ADR 0205).
55
58
  - [Table](Table.md): Records in rows that share named columns, so a reader can scan and compare them: transactions, members, invoices. A native `table` with parts for each element (`Table.Head`, `Table.Body`, `Table.Foot`, `Table.Row`, `Table.HeaderCell`, `Table.Cell`, `Table.ColumnGroup`, `Table.Column`), and `Table.ScrollArea` for a table wider than its container. It has no `grid` role and no roving focus: a link, `Checkbox` or `Menu` in a cell keeps the page's tab order, and a screen reader's table commands work as on any table.
56
59
  - [Tabs](Tabs.md): Switches between views that share one place on the page. The parts are `Tabs` (the root, a flex column; a row when vertical), `Tabs.List` (the `tablist`), `Tabs.Tab` (a `tab` button on `Clickable`) and `Tabs.Panel` (the `tabpanel`). Built on Base UI `Tabs` (ADR 0003, 0046): it owns the selection, one tab stop with arrow-key roving, `aria-selected`, and the ids that tie each tab to its panel. The selected tab shows an accent bar that fades and grows in (ADR 0049).
57
60
  - [Tag](Tag.md): A label that puts content in a category: a topic, a label, a user-made category. A `span` with a subtle tone fill (gray by default) and an `xs` (4px) radius (a small mark's step in `docs/shape.md`, so wrapped lines stay inside the fill) around a `Text` in the `label` font. It can be read-only, a link, or removable. `appearance="outline"` swaps the fill for a 1px border, a `med` (8px) radius and a small dot in the tone's color, for a quieter label among dense content.