@jonmilner/ui 0.22.0 → 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/Badge/Badge.css +1 -1
- package/dist/Body/index.d.mts +9 -0
- package/dist/Body/index.mjs +12 -0
- package/dist/Box/Box.css +1 -1
- package/dist/Button/Button.css +1 -1
- package/dist/Caption/index.d.mts +6 -0
- package/dist/Caption/index.mjs +14 -0
- package/dist/Checkbox/Checkbox.css +1 -1
- package/dist/Chip/Chip.css +1 -1
- package/dist/Clickable/Clickable.css +1 -1
- 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/Combobox/Combobox.css +2 -2
- package/dist/Dialog/Dialog.css +2 -2
- package/dist/Dialog/client.d.mts +1 -1
- package/dist/Dialog/client.mjs +14 -12
- package/dist/Dialog/index.d.mts +1 -1
- package/dist/Field/Field.css +1 -1
- 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 +1 -1
- package/dist/Inline/Inline.css +1 -1
- package/dist/Inline/index.mjs +1 -1
- 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 +2 -2
- package/dist/Menu/client.mjs +56 -77
- package/dist/Menu/item-row.mjs +2 -2
- package/dist/MultiSelect/MultiSelect.css +2 -2
- package/dist/NavList/NavList.css +1 -1
- package/dist/NumberField/NumberField.css +2 -2
- 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/SearchField/SearchField.css +2 -2
- package/dist/Select/Select.css +2 -2
- package/dist/Sidebar/Sidebar.css +1 -1
- package/dist/SidebarLayout/SidebarLayout.css +1 -1
- package/dist/Stack/Stack.css +1 -1
- package/dist/Stack/index.mjs +1 -1
- package/dist/Switch/Switch.css +1 -1
- package/dist/Table/Table.css +2 -2
- package/dist/Table/Table.css.mjs +4 -2
- package/dist/Table/index.d.mts +3 -9
- package/dist/Table/index.mjs +60 -74
- package/dist/Tabs/Tabs.css +1 -1
- package/dist/Tag/Tag.css +1 -1
- package/dist/Text/Text.css +1 -1
- package/dist/TextField/TextField.css +2 -2
- package/dist/Textarea/Textarea.css +2 -2
- package/dist/Toast/Toast.css +2 -2
- package/dist/Toast/Toast.css.mjs +10 -7
- package/dist/Toast/client.d.mts +3 -18
- package/dist/Toast/client.mjs +90 -132
- package/dist/Tooltip/Tooltip.css +1 -1
- 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.mjs +43 -35
- package/dist/contrast/mixes.mjs +15 -8
- 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 +2 -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/Inline.md +3 -2
- package/dist/docs/Label.md +77 -0
- package/dist/docs/Menu.md +3 -3
- package/dist/docs/MultiSelect.md +1 -0
- 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 +1 -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 +7 -7
- package/dist/docs/Tooltip.md +2 -2
- package/dist/docs/lint.md +18 -0
- package/dist/docs/llms.txt +19 -10
- package/dist/docs/manifest.json +557 -7
- 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 +3 -2
- package/dist/icons/index.mjs +4 -3
- package/dist/index.d.mts +11 -3
- package/dist/index.mjs +47 -40
- package/dist/lint/index.d.mts +20 -1
- package/dist/lint/index.mjs +18 -3
- package/dist/popup/client.mjs +20 -19
- package/dist/popup/direction.d.mts +2 -1
- package/dist/popup/positioner.mjs +27 -0
- 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/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,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
|
@@ -15,7 +15,7 @@ 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
|
|
|
@@ -307,8 +307,8 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
307
307
|
|
|
308
308
|
| Prop | Type | Required | Description |
|
|
309
309
|
| --- | --- | --- | --- |
|
|
310
|
-
| `aria-label` | `
|
|
311
|
-
| `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. |
|
|
312
312
|
| `children` | `ReactNode` | no | |
|
|
313
313
|
| `closeDelay` | `number` | no | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
|
|
314
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
|
@@ -101,6 +101,7 @@ A form field for picking any number of values from a list too long to show at on
|
|
|
101
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).
|
|
102
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.
|
|
103
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.
|
|
104
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.
|
|
105
106
|
|
|
106
107
|
## Props
|
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
|
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Popover
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Details about a control or row that would crowd the layout if always shown.
|
|
10
|
+
- Content the user opens on purpose and may act on: a link, a button, a few label and value rows.
|
|
11
|
+
- Something that should leave the page usable while it is open.
|
|
12
|
+
|
|
13
|
+
## When not to use
|
|
14
|
+
|
|
15
|
+
- A short hint on hover or focus, with nothing interactive: use `Tooltip`.
|
|
16
|
+
- A task that should stop the page until it is done or dismissed: use `Dialog`, or `AlertDialog` to confirm something destructive.
|
|
17
|
+
- A list of commands and nothing else: use `Menu`.
|
|
18
|
+
- Anything the user must see: put it on the page, since a popover is closed until someone opens it.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- Compose the parts: `Popover` > `Popover.Trigger` + `Popover.Popup` > your content, with `Popover.Close` if it needs a button that closes it. `Popover` holds the open state and renders no element, so it takes no `className` or `style`; every other part does, plus style props.
|
|
23
|
+
- `label` on `Popover.Popup` is required. It is the popup's accessible name, not shown: a short noun phrase, "Issue details". Screen readers announce the popup as a dialog with that name (ADR 0185).
|
|
24
|
+
- `Popover.Trigger` and `Popover.Close` are bare `Clickable`s: give them a look with style props, and an accessible name. Pass Button's `variant`, `size`, `iconStart`, `iconEnd` or `uppercase` and it renders a `Button`, which keeps the trigger's behavior and `aria-disabled` (ADR 0056).
|
|
25
|
+
- `disabled` on the trigger renders `aria-disabled`: it stays focusable and does not open.
|
|
26
|
+
- Pass `open` and `onOpenChange` to control it, `defaultOpen` to start open, and `onOpenChangeComplete` to act once the fade ends.
|
|
27
|
+
- `side` (`bottom` by default; `inline-start` and `inline-end` mirror under `rtl`) and `align` (`center`) place the popup against the trigger; it flips and shifts when it would overflow the viewport.
|
|
28
|
+
- The popup is at most 384px wide at the default font size, and never wider or taller than the room beside the trigger. Taller content scrolls the popup; content that long needs something focusable near its top, such as `Popover.Close`, so the scrolling region is reachable by keyboard (axe `scrollable-region-focusable`).
|
|
29
|
+
- Fill (`backgroundColor`, `bgRaised`), `borderRadius` (`med`), `boxShadow` (`med`), `overflow` (`auto`) and `padding` (`12`) are default style props on the popup: pass one to change it.
|
|
30
|
+
- The popup holds any content, so wrap text in `Text` yourself. Lay out rows with `Stack` and `Inline`.
|
|
31
|
+
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode, and sits on `zIndex` `popover`. That provider must not clip its content (see Menu).
|
|
32
|
+
- It is always non-modal and only opens on a click or tap: there is no `modal` prop and no hover mode (ADR 0185).
|
|
33
|
+
- Never add key handlers or `tabIndex` to the parts; Base UI handles the keyboard.
|
|
34
|
+
- The module has no hooks, so a server component can render the parts; `onOpenChange` must come from a client component.
|
|
35
|
+
|
|
36
|
+
## Do
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<Popover>
|
|
40
|
+
<Popover.Trigger size="sm" variant="secondary">
|
|
41
|
+
Details
|
|
42
|
+
</Popover.Trigger>
|
|
43
|
+
<Popover.Popup label="Issue details">
|
|
44
|
+
<Stack gap="4">
|
|
45
|
+
<Inline gap="12" justifyContent="space-between">
|
|
46
|
+
<Text color="fgMuted" size="sm">
|
|
47
|
+
State
|
|
48
|
+
</Text>
|
|
49
|
+
<Text size="sm">Queued</Text>
|
|
50
|
+
</Inline>
|
|
51
|
+
<Clickable as="a" href="/issues/617">
|
|
52
|
+
<Text size="sm">Open the issue</Text>
|
|
53
|
+
</Clickable>
|
|
54
|
+
</Stack>
|
|
55
|
+
</Popover.Popup>
|
|
56
|
+
</Popover>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Don't
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
// Hint on hover: use Tooltip.
|
|
63
|
+
<Popover.Popup label="Hint">Saved 3h ago</Popover.Popup>
|
|
64
|
+
|
|
65
|
+
// A form that must be finished before the page: use Dialog.
|
|
66
|
+
<Popover.Popup label="Rename">
|
|
67
|
+
<TextField label="Name" />
|
|
68
|
+
<Button onClick={save}>Save</Button>
|
|
69
|
+
</Popover.Popup>
|
|
70
|
+
|
|
71
|
+
// A list of commands and nothing else: use Menu.
|
|
72
|
+
<Popover.Popup label="Actions">
|
|
73
|
+
<Button onClick={edit}>Edit</Button>
|
|
74
|
+
<Button onClick={remove}>Delete</Button>
|
|
75
|
+
</Popover.Popup>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Accessibility
|
|
79
|
+
|
|
80
|
+
- The trigger is a real `<button>` with `aria-haspopup="dialog"`, `aria-expanded` and `aria-controls`. A disabled one is `aria-disabled` and stays in the tab order.
|
|
81
|
+
- The popup has `role="dialog"`, named by `label`, and no `aria-modal`: the page behind stays available to screen readers.
|
|
82
|
+
- Focus moves into the popup on open, and Tab reaches links and buttons inside. Esc or `Popover.Close` returns focus to the trigger. An outside press on something focusable leaves focus there; a press on anything else returns it to the trigger, except in browsers whose `focus()` lacks `preventScroll`.
|
|
83
|
+
- Motion is a zoom from the trigger plus a fade, a fade alone under `prefers-reduced-motion`. Under forced colors the popup keeps its border.
|
|
84
|
+
- The popup never grows wider or taller than the viewport beside the trigger: at 320px and 200% text it wraps and scrolls (WCAG 1.4.10).
|
|
85
|
+
|
|
86
|
+
## Props
|
|
87
|
+
|
|
88
|
+
Generated from the TypeScript types.
|
|
89
|
+
|
|
90
|
+
### Popover
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Required | Description |
|
|
93
|
+
| --- | --- | --- | --- |
|
|
94
|
+
| `children` | `ReactNode` | no | |
|
|
95
|
+
| `defaultOpen` | `boolean` | no | Whether the popover is initially open. To render a controlled popover, use the `open` prop instead. |
|
|
96
|
+
| `onOpenChange` | `((open: boolean, eventDetails: PopoverRootChangeEventDetails) => void)` | no | Event handler called when the popover is opened or closed. |
|
|
97
|
+
| `onOpenChangeComplete` | `((open: boolean) => void)` | no | Event handler called after any animations complete when the popover is opened or closed. |
|
|
98
|
+
| `open` | `boolean` | no | Whether the popover is currently open. |
|
|
99
|
+
|
|
100
|
+
### Popover.Close
|
|
101
|
+
|
|
102
|
+
| Prop | Type | Required | Description |
|
|
103
|
+
| --- | --- | --- | --- |
|
|
104
|
+
| `iconEnd` | `ComponentType` | no | |
|
|
105
|
+
| `iconStart` | `ComponentType` | no | |
|
|
106
|
+
| `size` | `"lg" \| "med" \| "sm"` | no | |
|
|
107
|
+
| `uppercase` | `boolean` | no | |
|
|
108
|
+
| `variant` | `"ghost" \| "primary" \| "secondary"` | no | |
|
|
109
|
+
|
|
110
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
111
|
+
|
|
112
|
+
### Popover.Popup
|
|
113
|
+
|
|
114
|
+
| Prop | Type | Required | Description |
|
|
115
|
+
| --- | --- | --- | --- |
|
|
116
|
+
| `align` | `"center" \| "end" \| "start"` | no | How to align the popup relative to the specified side. |
|
|
117
|
+
| `finalFocus` | `boolean \| RefObject<HTMLElement \| null> \| ((closeType: InteractionType) => void \| boolean \| HTMLElement \| null)` | no | Determines the element to focus when the popover 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, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing. |
|
|
118
|
+
| `initialFocus` | `boolean \| RefObject<HTMLElement \| null> \| ((openType: InteractionType) => void \| boolean \| HTMLElement \| null)` | no | Determines the element to focus when the popover is opened. By default, focus moves to the first tabbable element inside the popup, except when the popover is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - `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, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing. |
|
|
119
|
+
| `label` | `string` | yes | |
|
|
120
|
+
| `side` | `"bottom" \| "inline-end" \| "inline-start" \| "left" \| "right" \| "top"` | no | |
|
|
121
|
+
|
|
122
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
123
|
+
|
|
124
|
+
### Popover.Trigger
|
|
125
|
+
|
|
126
|
+
| Prop | Type | Required | Description |
|
|
127
|
+
| --- | --- | --- | --- |
|
|
128
|
+
| `iconEnd` | `ComponentType` | no | |
|
|
129
|
+
| `iconStart` | `ComponentType` | no | |
|
|
130
|
+
| `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 the popover in controlled mode (with the PopoverRoot `triggerId` prop). |
|
|
131
|
+
| `size` | `"lg" \| "med" \| "sm"` | no | |
|
|
132
|
+
| `uppercase` | `boolean` | no | |
|
|
133
|
+
| `variant` | `"ghost" \| "primary" \| "secondary"` | no | |
|
|
134
|
+
|
|
135
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/SearchField.md
CHANGED
|
@@ -104,7 +104,7 @@ const ref = useRef<HTMLInputElement>(null);
|
|
|
104
104
|
- The clear button is a named button in the tab order after the input. Activating it, by pointer or keyboard, empties the field and moves focus to the input, never to `body`.
|
|
105
105
|
- Escape clears without closing a surrounding Dialog; on an empty field it passes through.
|
|
106
106
|
- Showing and hiding the clear button shifts nothing: the input's inline-end padding always holds it.
|
|
107
|
-
- Invalid adds a danger border and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall, and the clear button meets the 24 by 24 CSS px target size. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
107
|
+
- Invalid adds a 2px danger border, a 2px `CanvasText` border under forced colors, and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall, and the clear button meets the 24 by 24 CSS px target size. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
108
108
|
|
|
109
109
|
## Props
|
|
110
110
|
|
package/dist/docs/Select.md
CHANGED
|
@@ -99,6 +99,7 @@ A form field for picking one value from a list too long to show as radios, with
|
|
|
99
99
|
- 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 is the only one a screen reader or a role query finds (ADR 0113).
|
|
100
100
|
- 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.
|
|
101
101
|
- The trigger's value is text; a truncated label keeps its full text for assistive technology.
|
|
102
|
+
- 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.
|
|
102
103
|
- 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.
|
|
103
104
|
|
|
104
105
|
## Props
|
package/dist/docs/Stack.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
A vertical column of children with even space between them. `Stack` is a `Box` with `display="flex"`
|
|
5
|
+
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.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
24
24
|
- Space comes from `gap`, never from margins on the children.
|
|
25
25
|
- It takes every `Box` prop, and the layout defaults are style props, so `display`, `flexDirection` and `alignItems` override them.
|
|
26
26
|
- Children are not wrapped, so each child is a flex item: it stretches to the column's width unless `alignItems` says otherwise.
|
|
27
|
-
- A list needs no `className` or stylesheet. `paddingInlineStart="0"` drops the `ul` indent, and a row that is
|
|
27
|
+
- A list needs no `className` or stylesheet. `paddingInlineStart="0"` drops the `ul` indent, and a row that is an `Inline as="li"` (or a `Stack as="li"`) is a flex container, so it draws no marker.
|
|
28
28
|
- The consumer's `className` comes last and `style` is passed through; `ref` is a plain prop typed for the `as` element.
|
|
29
29
|
|
|
30
30
|
## Do
|
|
@@ -32,7 +32,7 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
32
32
|
```tsx
|
|
33
33
|
<Stack gap="24">
|
|
34
34
|
<Heading>Settings</Heading>
|
|
35
|
-
<
|
|
35
|
+
<Body>Choose how the app looks.</Body>
|
|
36
36
|
</Stack>
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -43,19 +43,21 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
```tsx
|
|
46
|
-
// A styled list with no className:
|
|
46
|
+
// A styled list with no className: each row is an Inline, a flex `li` that draws no marker.
|
|
47
47
|
<Stack as="ul" gap="8" paddingInlineStart="0" aria-label="Projects">
|
|
48
48
|
{projects.map((project) => (
|
|
49
|
-
<
|
|
49
|
+
<Inline
|
|
50
50
|
as="li"
|
|
51
51
|
key={project.id}
|
|
52
|
-
|
|
52
|
+
gap="8"
|
|
53
|
+
justifyContent="space-between"
|
|
53
54
|
padding="12"
|
|
54
55
|
backgroundColor="bgRaised"
|
|
55
56
|
borderRadius="med"
|
|
56
57
|
>
|
|
57
|
-
<
|
|
58
|
-
|
|
58
|
+
<Label>{project.name}</Label>
|
|
59
|
+
<Caption>{project.updated}</Caption>
|
|
60
|
+
</Inline>
|
|
59
61
|
))}
|
|
60
62
|
</Stack>
|
|
61
63
|
```
|
|
@@ -80,10 +82,10 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
80
82
|
// A wrapper only to space children adds a needless element; Stack spaces them directly.
|
|
81
83
|
<Stack gap="16">
|
|
82
84
|
<div>
|
|
83
|
-
<
|
|
85
|
+
<Label>Name</Label>
|
|
84
86
|
</div>
|
|
85
87
|
<div>
|
|
86
|
-
<
|
|
88
|
+
<Label>Email</Label>
|
|
87
89
|
</div>
|
|
88
90
|
</Stack>
|
|
89
91
|
```
|
package/dist/docs/Table.md
CHANGED
|
@@ -33,7 +33,7 @@ Records in rows that share named columns, so a reader can scan and compare them:
|
|
|
33
33
|
- Body rows take a light hover tint only where hover is real (`(hover: hover)`); it never means anything, it only helps the eye follow a row. On a `bgMuted` surface, colored text in a cell (`color="danger"`) falls under 4.5:1 under the tint: put a status there in a `Badge`.
|
|
34
34
|
- `layout`: `auto` (default) sizes columns from their content; `fixed` sizes them from the first row and the columns' widths, so it is faster on a long table and its columns stay put. Set a width with `inlineSize` on `Table.Column` inside `Table.ColumnGroup`: a size step, a container width, `auto`, `full` or `fit`. A width no token gives goes in `className`, the documented exception.
|
|
35
35
|
- The table is `inlineSize="full"` by default. Cells have `8` block and `12` inline padding as default style props, and a `border` rule below each. Every part takes `className`, `style`, `ref` and the style props; the consumer's win.
|
|
36
|
-
- `sort` (`"ascending"`, `"descending"` or `"none"`) and `onSort` on a `HeaderCell` make its column sortable: its label goes in a button, with an up or down arrow after it for the current order (an unsorted column keeps the arrow's room,
|
|
36
|
+
- `sort` (`"ascending"`, `"descending"` or `"none"`) and `onSort` on a `HeaderCell` make its column sortable: its label goes in a button, with an up or down arrow after it for the current order (an unsorted column keeps the arrow's room, and shows the arrow there only while its button is hovered or keyboard-focused, so sortable columns reveal themselves; touch users get no cue at rest), and the sorted column's label turns `fg`. Pressing it calls `onSort`; the app re-sorts its rows and passes the new `sort`, and picks the press order (a new column ascending, the same one flipped). Pass `"none"` on each sortable column that is not the sorted one. `sort` and `onSort` go together, and `hideLabel` cannot join them: the label is the button's name.
|
|
37
37
|
- `sort` sets `aria-sort` on the header, only while the column is ascending or descending. A header sorted some other way (a link, the server) passes `aria-sort` itself and leaves `sort` unset.
|
|
38
38
|
- `Table.ScrollArea` wraps one `Table` that may outgrow its container, and scrolls it sideways inside a `section`. Its type requires a name, the table's again (`aria-label` or `aria-labelledby`), since a focusable region is announced on its own. It is in the tab order only while the table overflows, and keeps `8` of room below the table for its scroll thumb, so nothing moves when the thumb shows. Style props, `className` and `style` go on its root; its other props, `ref` included, on the `section`. It takes no block size: it scrolls sideways only.
|
|
39
39
|
- No part has hooks, so a server component can render the whole table. `onSort` is a function, so a sortable table renders from a client component.
|
|
@@ -161,7 +161,7 @@ const header = (key: "payee" | "amount") => ({
|
|
|
161
161
|
|
|
162
162
|
- Native table semantics: rows, column and row headers are announced, and screen readers' table navigation works. Column headers are `scope="col"`; set `scope="row"` on a row's first cell when it names the row.
|
|
163
163
|
- A `caption`, `aria-label` or `aria-labelledby` names the table (WCAG 1.3.1).
|
|
164
|
-
- A sortable header is a native `button` named by its label, in the tab order, pressed with Enter, Space or a click; its arrow is hidden from assistive tech, and the `th`'s `aria-sort` announces the order (WAI-ARIA sortable table pattern).
|
|
164
|
+
- A sortable header is a native `button` named by its label, in the tab order, pressed with Enter, Space or a click; its arrow, the unsorted hover and focus cue included, is hidden from assistive tech, and the `th`'s `aria-sort` announces the order (WAI-ARIA sortable table pattern).
|
|
165
165
|
- `Table.ScrollArea` scrolls a wide table inside itself, so the page does not scroll sideways at 320 CSS px (WCAG 1.4.10). While the table overflows, Base UI puts the region in the tab order and the arrow keys scroll it (WCAG 2.1.1, axe `scrollable-region-focusable`); it shows the focus ring just inside its edge, so a dialog body or the page edge never clips it, and is announced by its name as a region. Before the page hydrates it scrolls by touch, trackpad or mouse only. Its scroll thumb is hidden from assistive tech.
|
|
166
166
|
- Controls in cells are in the tab order, in reading order. Give each a name that says its row ("Select Ada Lovelace", "Actions for City Water").
|
|
167
167
|
- A pending row's `aria-busy` tells assistive tech it is changing; a toned row's meaning is in its text (WCAG 1.4.1).
|
|
@@ -234,7 +234,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
234
234
|
| `hideLabel` | `boolean` | no | |
|
|
235
235
|
| `leading` | `"body" \| "lg" \| "med" \| "meta" \| "sm"` | no | |
|
|
236
236
|
| `numeric` | `boolean` | no | |
|
|
237
|
-
| `onSort` | `((
|
|
237
|
+
| `onSort` | `(() => void) & (() => void)` | no | |
|
|
238
238
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
239
239
|
| `sort` | `"ascending" \| "descending" \| "none"` | no | |
|
|
240
240
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
@@ -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 |
|
|
258
|
-
| `aria-labelledby` | `string` | no |
|
|
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. |
|
|
259
259
|
|
|
260
260
|
Also accepts the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/Text.md
CHANGED
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
The base of all visible text, and the primitive every text component builds on. Its box is trimmed to the cap height and the baseline, so the gap around text is the visible space and text sits centred in a padded control. It takes every Box style prop (`color`, `textAlign`, margins), plus `size`, `font`, `weight`, `leading`, `truncate` and `wrap`.
|
|
5
|
+
The base of all visible text, and the primitive every text component builds on. Its box is trimmed to the cap height and the baseline, so the gap around text is the visible space and text sits centred in a padded control. It takes every Box style prop (`color`, `textAlign`, margins), plus `size`, `font`, `weight`, `leading`, `truncate` and `wrap`. An app almost never renders it directly: rendering `Text` is a code smell, since `Heading`, `Body`, `Label`, `Caption` and `Code` cover a string a user sees.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
9
|
-
- Body copy, labels, captions, code: any string a user sees.
|
|
10
9
|
- Building a text component (a heading, a label, a badge's text): render `Text` with defaults, as `Heading` does.
|
|
11
|
-
- A run inside a line (`strong`, `em`, `code`): a `Text` rendered as a phrasing element directly inside another `Text` is inline and untrimmed, and inherits the outer font until its own props say otherwise.
|
|
10
|
+
- A run inside a line (`strong`, `em`, `time`; for code, use `Code`): a `Text` rendered as a phrasing element directly inside another `Text` is inline and untrimmed, and inherits the outer font until its own props say otherwise.
|
|
11
|
+
- What no typography component covers: preformatted text that wraps (`as="pre"` with `wrap="pre-wrap"`), or prose in the mono font that is not code.
|
|
12
12
|
|
|
13
13
|
## When not to use
|
|
14
14
|
|
|
15
|
+
- Any other string a user sees: use a typography component.
|
|
15
16
|
- Section and page headings: use `Heading`, which picks the element by level.
|
|
16
|
-
-
|
|
17
|
+
- Running text: use `Body`. Short UI text that names something: use `Label`. A muted note (a timestamp, a count): use `Caption`. Code: use `Code`.
|
|
18
|
+
- Layout around text: put the text in a `Stack` or `Inline` and set the gap there, or in a `Box` for a surface.
|
|
17
19
|
|
|
18
20
|
## Rules
|
|
19
21
|
|
|
20
|
-
- `as` defaults to `p`, so a run inside a paragraph must set an inline element: `as="span"`, `"strong"`, `"em"`, `"code
|
|
22
|
+
- `as` defaults to `p`, so a run inside a paragraph must set an inline element: `as="span"`, `"strong"`, `"em"`, `"time"`; code is `Code`, not `as="code"`. A `p` inside a `p` is invalid HTML and breaks hydration.
|
|
21
23
|
- A run inherits the outer weight, so `<Text as="strong">` is not bold until it sets `weight="bold"` (or `semibold`).
|
|
22
24
|
- A run is inline whatever its `display` prop, and `truncate` gives it no ellipsis; truncate a block Text instead.
|
|
23
|
-
- Do not set `display="flex"` or `"grid"`: natively the box is not trimmed, and on the fallback the trim pseudo-elements become flex or grid items that `gap` spaces. Wrap the text in a
|
|
25
|
+
- Do not set `display="flex"` or `"grid"`: natively the box is not trimmed, and on the fallback the trim pseudo-elements become flex or grid items that `gap` spaces. Wrap the text in a `Stack` or `Inline` for layout instead. A block element (`p`, `div`, `h2`) or a Text inside a `Box` inside a Text keeps its own trimmed box.
|
|
24
26
|
- `size` takes a `fontSize` step: `xs`, `sm`, `med`, `lg`, `xl`, `2xl`, `3xl`, `4xl`. The top-level default is `med`.
|
|
25
27
|
- `font` takes a font role: `body` (default), `heading`, `display`, `label`, `mono`. The brand maps roles to fonts.
|
|
26
28
|
- `weight` takes `regular` (default), `medium`, `semibold` or `bold`.
|
|
@@ -35,7 +37,7 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
35
37
|
- `wrap="pre"` keeps newlines and runs of spaces on unwrapped lines, so a long line overflows its box: aligned output whose columns must not reflow. Where the box cannot grow, use `pre-wrap`.
|
|
36
38
|
- `truncate` wins over `wrap`: a Text with both keeps one line, collapses whitespace and ignores `wrap`.
|
|
37
39
|
- Plain wrapped text with a long unbroken string and no whitespace to keep has no `wrap` value; its component sets `overflow-wrap` in its own styles.
|
|
38
|
-
- A list item's text is a Text directly inside the `li`: `<li><
|
|
40
|
+
- A list item's text is a Text, or a typography component built on it, directly inside the `li`: `<li><Label>…</Label></li>`. At its default `display`, that Text keeps the marker on its first line at the trimmed height; with another `display` it does not. Do not render the Text as the `li` itself. Trimmed items touch, so space them with the list's `gap`: `<Stack as="ul" gap="8">`. The marker takes the body font, whatever the `li` or the Text's `font` sets; to change it, style `li::marker`.
|
|
39
41
|
- The trim has two paths (ADR 0160). Where the browser supports `text-box: trim-both cap alphabetic`, Text uses it, exact at the engine's own glyph positions. Elsewhere capsize trims with two pseudo-elements from the brand's font metrics, which can sit up to 0.8px off centre. Both give the same box height, so layout does not change between them.
|
|
40
42
|
- Do not style `::before` or `::after` on a Text: the fallback path uses them.
|
|
41
43
|
- To clip a Text, use `truncate` or `overflow="clip"`. At `overflow="hidden"` or `"auto"` it is a scroll container, which Firefox does not trim natively, so Text trims it with the pseudo-elements on both paths; set those through the `overflow` prop, never a class or `style`.
|
|
@@ -43,28 +45,28 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
43
45
|
## Do
|
|
44
46
|
|
|
45
47
|
```tsx
|
|
46
|
-
|
|
48
|
+
// A run inside a typography component: Caption is a Text, so the `time` is inline.
|
|
49
|
+
<Caption>
|
|
47
50
|
Updated{" "}
|
|
48
51
|
<Text as="time" dateTime="2026-10-23">
|
|
49
52
|
today
|
|
50
53
|
</Text>
|
|
51
|
-
</
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```tsx
|
|
55
|
-
<Text as="span" font="label" weight="medium" truncate>
|
|
56
|
-
{fileName}
|
|
57
|
-
</Text>
|
|
54
|
+
</Caption>
|
|
58
55
|
```
|
|
59
56
|
|
|
60
57
|
```tsx
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// Building a text component: Text with its defaults, as Label is.
|
|
59
|
+
function Eyebrow({ children }: { children: ReactNode }) {
|
|
60
|
+
return (
|
|
61
|
+
<Text as="span" font="label" size="xs" weight="medium" leading="meta" color="fgMuted">
|
|
62
|
+
{children}
|
|
63
|
+
</Text>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
```tsx
|
|
67
|
-
<Text as="pre"
|
|
69
|
+
<Text as="pre" size="sm" wrap="pre-wrap">
|
|
68
70
|
{commitMessage}
|
|
69
71
|
</Text>
|
|
70
72
|
```
|
|
@@ -73,9 +75,7 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
73
75
|
<Stack as="ul" gap="8">
|
|
74
76
|
{files.map((file) => (
|
|
75
77
|
<li key={file}>
|
|
76
|
-
<
|
|
77
|
-
{file}
|
|
78
|
-
</Text>
|
|
78
|
+
<Label font="mono">{file}</Label>
|
|
79
79
|
</li>
|
|
80
80
|
))}
|
|
81
81
|
</Stack>
|
|
@@ -88,6 +88,13 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
88
88
|
<Text color="#666" size="md" />
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
```tsx
|
|
92
|
+
// Text rendered directly for what a typography component covers: use `<Label truncate>`.
|
|
93
|
+
<Text as="span" font="label" size="sm" weight="medium" truncate>
|
|
94
|
+
{fileName}
|
|
95
|
+
</Text>
|
|
96
|
+
```
|
|
97
|
+
|
|
91
98
|
```tsx
|
|
92
99
|
// Text outside Text: untrimmed, in no font role.
|
|
93
100
|
<Box>Saved</Box>
|
|
@@ -102,7 +109,7 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
102
109
|
|
|
103
110
|
## Accessibility
|
|
104
111
|
|
|
105
|
-
- Text adds no role or ARIA. Pick the element with `as` so the meaning is right: `p`, `label`, `time`, `
|
|
112
|
+
- Text adds no role or ARIA. Pick the element with `as` so the meaning is right: `p`, `label`, `time`, `strong`.
|
|
106
113
|
- Color alone carries no meaning: `fgMuted` text needs words that say the same.
|
|
107
114
|
- Truncated text is cut for everyone; put the full string somewhere reachable (the page it links to, an accessible name), not only in a tooltip.
|
|
108
115
|
|
package/dist/docs/TextField.md
CHANGED
|
@@ -89,7 +89,7 @@ A form field for one line of text that is not a search: an `<input>` (role `text
|
|
|
89
89
|
## Accessibility
|
|
90
90
|
|
|
91
91
|
- The input is a `textbox` named by the label, visible or not.
|
|
92
|
-
- Invalid adds a danger border and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
92
|
+
- Invalid adds a 2px danger border, a 2px `CanvasText` border under forced colors, and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the input text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
93
93
|
- `type="email"`, `"url"` and `"tel"` bring the platform's keyboard on touch devices; the role stays `textbox`.
|
|
94
94
|
|
|
95
95
|
## Props
|
package/dist/docs/Textarea.md
CHANGED
|
@@ -72,7 +72,7 @@ A form field for several lines of free text: a `<textarea>` (role `textbox`, mul
|
|
|
72
72
|
## Accessibility
|
|
73
73
|
|
|
74
74
|
- The textarea is a multi-line `textbox` named by the label, visible or not.
|
|
75
|
-
- Invalid adds a danger border and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
75
|
+
- Invalid adds a 2px danger border, a 2px `CanvasText` border under forced colors, and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
76
76
|
- Text longer than the box scrolls inside it, with the keyboard as with a pointer; the page around it does not move.
|
|
77
77
|
|
|
78
78
|
## Props
|
package/dist/docs/Toast.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
Tells the user briefly about the result of an action without interrupting them: "Changes saved", "Message sent", "Couldn't upload the file". Material calls it a snackbar and Atlassian a flag. Built on Base UI's Toast, which owns the queue, the timers and swipe-to-dismiss. The parts add the look: a
|
|
5
|
+
Tells the user briefly about the result of an action without interrupting them: "Changes saved", "Message sent", "Couldn't upload the file". Material calls it a snackbar and Atlassian a flag. Built on Base UI's Toast, which owns the queue, the timers and swipe-to-dismiss. The parts add the look: a card tinted by variant in a stack at the bottom end corner, an icon per variant, a close button, and a slide-up-and-fade that is a plain fade under reduced motion. A toast never takes focus and moves nothing on the page.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
@@ -16,16 +16,16 @@ Tells the user briefly about the result of an action without interrupting them:
|
|
|
16
16
|
- A focused task, or anything with fields: use `Dialog`. A toast holds no form fields.
|
|
17
17
|
- An error on one input: use the `Field`'s error message, on the field.
|
|
18
18
|
- A status that stays (draft, synced, 3 unread): use `Badge`.
|
|
19
|
-
- A message that must stay on the page until its cause is fixed (offline, trial ending):
|
|
19
|
+
- A message that must stay on the page until its cause is fixed (offline, trial ending): use `Alert`.
|
|
20
20
|
- Anything the user must read or act on to continue: a toast may close before they reach it.
|
|
21
21
|
|
|
22
22
|
## Rules
|
|
23
23
|
|
|
24
24
|
- Wrap the app once in `Toast.Provider`, inside its `ThemeProvider`. Show a toast from any client component under it with `useToast()`: `add(options)` returns the toast's id, `close(id)` dismisses it.
|
|
25
25
|
- `title` is one line on what happened. `description` is one optional sentence more. Both are plain strings.
|
|
26
|
-
- `variant` is `info` (the default), `success` or `
|
|
27
|
-
- `action` takes a `label` and an `onClick`; there is at most one. Choosing it also closes the toast. Nothing essential goes there: Undo is fine when the user could also undo another way; "Retry" on
|
|
28
|
-
- `duration` is how long, in milliseconds, before the toast closes itself; `0` keeps it until the user dismisses it. It defaults to 5000, and to 0 for `
|
|
26
|
+
- `variant` is `info` (the default), `success`, `warning` or `danger`. Each has its own icon, so the variant never rests on color alone, and its tone's subtle fill and text: `accent`, `success`, `warning` and `danger`.
|
|
27
|
+
- `action` takes a `label` and an `onClick`; there is at most one. Choosing it also closes the toast. Nothing essential goes there: Undo is fine when the user could also undo another way; "Retry" on a `danger` toast is fine because it stays until it is dismissed.
|
|
28
|
+
- `duration` is how long, in milliseconds, before the toast closes itself; `0` keeps it until the user dismisses it. It defaults to 5000, and to 0 for `danger`, so the user always gets time to read an error.
|
|
29
29
|
- `onClose` is called once when the toast closes, however it closes: its close button, Escape, a swipe, its timer, its action, or `close(id)`. It takes no reason, so it cannot tell a user's dismissal from the app's own `close(id)`. Use it to remember a notice was seen, such as one that should not come back on reload.
|
|
30
30
|
- Every toast has a close button. `closeLabel` on the provider names it for every toast ("Dismiss" by default) and `regionLabel` names the stack's landmark ("Notifications" by default); translate both there.
|
|
31
31
|
- `limit` on the provider (3 by default) caps how many show at once: the newest. Older ones are hidden until a newer one leaves, so an error that stays until dismissed can be hidden by later toasts. The newest sits at the top, nearest the content.
|
|
@@ -53,7 +53,7 @@ async function save() {
|
|
|
53
53
|
toast.add({
|
|
54
54
|
title: "Couldn't save your profile",
|
|
55
55
|
description: "Check your connection and try again.",
|
|
56
|
-
variant: "
|
|
56
|
+
variant: "danger",
|
|
57
57
|
action: { label: "Retry", onClick: save },
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -90,7 +90,7 @@ toast.add({ title: "Update", description: releaseNotes });
|
|
|
90
90
|
|
|
91
91
|
## Accessibility
|
|
92
92
|
|
|
93
|
-
- The stack is a `region` landmark named by `regionLabel` ("Notifications" by default); F6 moves focus to it, and Shift+Tab from there returns focus where it was. Each toast is a `group` named by its title. Neither the stack (`aria-live="off"`) nor the toasts are live regions; the provider renders two visually hidden ones that exist before any toast, and adds each toast's title and description to one as it arrives: `info` and `
|
|
93
|
+
- The stack is a `region` landmark named by `regionLabel` ("Notifications" by default); F6 moves focus to it, and Shift+Tab from there returns focus where it was. Each toast is a `group` named by its title. Neither the stack (`aria-live="off"`) nor the toasts are live regions; the provider renders two visually hidden ones that exist before any toast, and adds each toast's title and description to one as it arrives: `info`, `success` and `warning` to a polite `status`, `danger` to an assertive `alert`. So each toast is announced once, and an error at once (ADR 0074). Adding a toast never moves focus.
|
|
94
94
|
- A toast hidden by `limit` was announced when it arrived. When a newer one leaves and it shows again, it is not announced a second time; a user who needs it finds it in the stack with F6.
|
|
95
95
|
- An error raised from inside a modal `Dialog` is still announced: the dialog hides the rest of the page from assistive tech, but not the announcer's regions.
|
|
96
96
|
- Inside a modal `Dialog`: F6 still reaches the stack past the dialog's focus trap, so an error's action and close button stay in keyboard reach; Tab past the last toast returns focus to the dialog. Escape on a toast closes only the toast; the dialog, and what was typed in it, stays (ADR 0132). Escape anywhere in the stack goes no further, so on the stack itself it does nothing, and an app's own `document` or `window` Escape listener never sees it.
|
package/dist/docs/Tooltip.md
CHANGED
|
@@ -12,7 +12,7 @@ A short hint about a control that shows on hover after a delay and at once on ke
|
|
|
12
12
|
## When not to use
|
|
13
13
|
|
|
14
14
|
- Anything essential: the only name of a control, an error, an instruction a user must follow. Put it on the page, in the trigger's name, or in a Field's `description` (ADR 0116, 0147).
|
|
15
|
-
- Interactive content (links, buttons, fields): a tooltip closes when the pointer or focus leaves its trigger. Use
|
|
15
|
+
- Interactive content (links, buttons, fields): a tooltip closes when the pointer or focus leaves its trigger. Use `Popover`, or `Dialog` when the page should wait.
|
|
16
16
|
- Naming an icon-only button: IconButton's `label` names it, and IconButton gets no tooltip (ADR 0083).
|
|
17
17
|
- Showing a truncated Tag's full text: Tag wraps it in place on hover and focus (ADR 0055).
|
|
18
18
|
- Long content: keep it to a sentence or a few short rows.
|
|
@@ -31,7 +31,7 @@ A short hint about a control that shows on hover after a delay and at once on ke
|
|
|
31
31
|
- Children with a string or number among them (`{failed} of {total} checks failed`, a sentence with a `<strong>`) render in one `Text size="sm"`. Anything else renders as given: a lone `<strong>`, a fragment or a component that returns text needs its own `Text size="sm"`. For rows, pass `Stack` and `Inline` with `Text size="sm"` and no bare text; they are read as one description, so keep them few.
|
|
32
32
|
- `side` (`top` by default) and `align` (`center`) place the popup against the trigger; it flips when it would overflow the viewport, and never grows wider than the space beside the trigger.
|
|
33
33
|
- Fill (`backgroundColor`, `bgRaised`), `borderRadius` (`xs`), `boxShadow` (`med`), `paddingBlock` (`4`) and `paddingInline` (`8`) are default style props on the popup: pass one to change it.
|
|
34
|
-
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode, and sits on `zIndex` `tooltip`, above
|
|
34
|
+
- The popup portals into the trigger's nearest `ThemeProvider`, so it keeps the brand and mode, and sits on `zIndex` `tooltip`, above `Popover` and `Dialog`. That provider must not clip its content (see Menu).
|
|
35
35
|
- Never add key handlers or `tabIndex` to the parts; Base UI handles the keyboard.
|
|
36
36
|
- The module has no hooks, so a server component can render the parts; `onOpenChange` must come from a client component.
|
|
37
37
|
|