@kb.ui/react 0.12.1 → 0.13.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 +4 -0
- package/dist/components/Button/Button.d.ts +3 -1
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/FilterChip/FilterChip.d.ts +29 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +12 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +12 -0
- package/dist/components/Toolbar/Toolbar.d.ts +1 -0
- package/dist/components/TreeList/TreeList.d.ts +27 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +856 -624
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/components/Button.md +6 -0
- package/docs/components/Dialog.md +4 -2
- package/docs/components/FilterChip.md +74 -0
- package/docs/components/ToggleButton.md +53 -0
- package/docs/components/ToggleGroup.md +59 -0
- package/docs/components/TreeList.md +64 -0
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ export function Example() {
|
|
|
19
19
|
|
|
20
20
|
- [Styled navigation](https://kbui.kcb.pro/storybook/?path=/story/components-button--as-link): Render a link with the correct semantics.
|
|
21
21
|
- [Icon-only actions](https://kbui.kcb.pro/storybook/?path=/story/components-button--icon-only): Give the action an accessible name.
|
|
22
|
+
- Show a pending action without moving surrounding controls. [Loading story](https://kbui.kcb.pro/storybook/?path=/story/components-button--loading)
|
|
22
23
|
- [Size choices](https://kbui.kcb.pro/storybook/?path=/story/components-button--sizes): Compare button sizes.
|
|
23
24
|
|
|
24
25
|
## Reference
|
|
@@ -29,6 +30,7 @@ export function Example() {
|
|
|
29
30
|
| `variant` | `"primary" \| "secondary" \| "ghost" \| "danger"` | `"primary"` | Main, supporting, quiet, or destructive action emphasis |
|
|
30
31
|
| `size` | `sm` / `md` / `lg` / `icon` | `md` | Height and padding; `icon` is square and requires `aria-label` |
|
|
31
32
|
| `type` | native `button` type | `button` | Set `type="submit"` for form submission; use `type="button"` for other form actions |
|
|
33
|
+
| `loading` | `boolean` | `false` | Shows a decorative spinner, sets `aria-busy` and `aria-disabled`, and blocks repeat activation while retaining focus and width. |
|
|
32
34
|
| `disabled` | `boolean` | `false` | Blocks interaction; explain unavailable actions in nearby text when needed |
|
|
33
35
|
| `render` | element | unset | Use an anchor with `nativeButton={false}` and `role="link"` for navigation |
|
|
34
36
|
| `className` | `string` | unset | Extra classes on the rendered control; function values are not supported |
|
|
@@ -41,6 +43,10 @@ All props accepted by a native `button` or Base UI's `Button` also work. To rend
|
|
|
41
43
|
</Button>
|
|
42
44
|
```
|
|
43
45
|
|
|
46
|
+
## Loading an action
|
|
47
|
+
|
|
48
|
+
Pass `loading={pending}` while the action is running and keep the children stable so the button retains its name and width. The spinner fades in over the label area and appears instantly with reduced motion. The button can keep keyboard focus while loading. An explicitly disabled native button retains its normal disabled behavior. Keep any progress, success or failure message that should be announced in a separate status or alert region.
|
|
49
|
+
|
|
44
50
|
## Related components
|
|
45
51
|
|
|
46
52
|
Use [`Link`](Link.md) for navigation. Group coordinated actions with [`Toolbar`](Toolbar.md), or independent wrapping actions with [`Inline`](Inline.md).
|
|
@@ -41,7 +41,7 @@ export function Example() {
|
|
|
41
41
|
| `Dialog` | Root. Accepts `open`, `defaultOpen` and `onOpenChange` for controlled use. |
|
|
42
42
|
| `Dialog.Trigger` | Opens the dialog. Use `render={<Button />}` to style it as a button. |
|
|
43
43
|
| `Dialog.Content` | The dialog. `title` and `description` set its accessible name and description; `container` changes where it mounts. |
|
|
44
|
-
| `Content.layout` | `"center"` (default) or `"drawer"`; drawer slides from inline end
|
|
44
|
+
| `Content.layout` | `"center"` (default) or `"drawer"`; drawer slides from inline end above 550 CSS pixels and opens as a bottom sheet at narrower widths, including 550 pixels. The direct Body scrolls independently. |
|
|
45
45
|
| `Dialog.Title`, `Dialog.Description` | For custom layouts. Use these or the `Dialog.Content` props in a given dialog, not both, or it gets two titles. |
|
|
46
46
|
| `Dialog.Header`, `Dialog.Body`, `Dialog.Footer` | Optional structured sections; accept native `div` props and refs. Centered padding follows `--kb-dialog-{header,body,footer}-padding`; drawer sections use `--kb-dialog-padding`. |
|
|
47
47
|
| `Dialog.Actions` | Aligns buttons along the bottom right. |
|
|
@@ -76,7 +76,9 @@ Use [`ConfirmAction`](ConfirmAction.md) for a destructive action behind a confir
|
|
|
76
76
|
|
|
77
77
|
## Drawer and confirmation patterns
|
|
78
78
|
|
|
79
|
-
The [overlay guide](../../../../docs/guides/forms-and-overlays.md#drawer-pattern) supplies complete drawer and asynchronous confirmation modules.
|
|
79
|
+
The [overlay guide](../../../../docs/guides/forms-and-overlays.md#drawer-pattern) supplies complete drawer and asynchronous confirmation modules. Use `Content layout="drawer"` for plain content or add direct `Dialog.Header`, `Dialog.Body` and `Dialog.Footer` sections. Header and footer stay visible while the body scrolls. On wide screens the drawer follows logical direction and fills the dynamic viewport height. The narrow layout spans the full width and respects the safe area while remaining open through viewport changes. Content title/description props automatically form a drawer Header. Focus a composed title initially for long content. Confirmations focus Cancel first, reject duplicate/pending dismissal, retain errors for retry and close only after success.
|
|
80
|
+
|
|
81
|
+
The drawer fades and moves a short distance from the viewport edge. On narrow screens, the drawer keeps plain content and section contents inside the device’s safe area. The structured sections span the drawer width and use up to one rem of base padding.
|
|
80
82
|
|
|
81
83
|
- [Drawer](https://kbui.kcb.pro/storybook/?path=/story/components-dialog--drawer)
|
|
82
84
|
- [Failure and retry](https://kbui.kcb.pro/storybook/?path=/story/components-dialog--confirmation-recovery)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# FilterChip
|
|
2
|
+
|
|
3
|
+
Show a filter the user can select, remove, or both. Keep its label short and stable when selection changes.
|
|
4
|
+
|
|
5
|
+
[All components](../../README.md#components) · [Usage](#usage) · [Examples](#more-examples) · [Reference](#reference) · [Live examples and accessibility](https://kbui.kcb.pro/storybook/?path=/docs/components-filterchip--docs)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Pass `selected` and `onSelectedChange` to show a toggle button. Pass `onRemove` to show a remove button. The application owns which filters are selected or rendered. If removing a chip clears the focused control, move focus to a useful remaining control, such as the next filter or the control that adds filters.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import "@kb.ui/react/styles.css";
|
|
13
|
+
import { Button, FilterChip, Inline } from "@kb.ui/react";
|
|
14
|
+
import { useRef, useState } from "react";
|
|
15
|
+
|
|
16
|
+
export function AvailabilityFilter() {
|
|
17
|
+
const [availableOnly, setAvailableOnly] = useState(false);
|
|
18
|
+
return (
|
|
19
|
+
<FilterChip
|
|
20
|
+
label="Available now"
|
|
21
|
+
selected={availableOnly}
|
|
22
|
+
onSelectedChange={setAvailableOnly}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function AppliedFilters() {
|
|
28
|
+
const [regionalOnly, setRegionalOnly] = useState(true);
|
|
29
|
+
const applyFilter = useRef<HTMLButtonElement>(null);
|
|
30
|
+
return (
|
|
31
|
+
<Inline gap="sm">
|
|
32
|
+
{regionalOnly && (
|
|
33
|
+
<FilterChip
|
|
34
|
+
label="My region"
|
|
35
|
+
onRemove={() => {
|
|
36
|
+
setRegionalOnly(false);
|
|
37
|
+
applyFilter.current?.focus();
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
<Button ref={applyFilter} onClick={() => setRegionalOnly(true)}>
|
|
42
|
+
Apply region filter
|
|
43
|
+
</Button>
|
|
44
|
+
</Inline>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## More examples
|
|
50
|
+
|
|
51
|
+
- [Select a filter](https://kbui.kcb.pro/storybook/?path=/story/components-filterchip--default). Press Space or Enter to toggle the named filter and keep focus on it.
|
|
52
|
+
- [Remove a filter](https://kbui.kcb.pro/storybook/?path=/story/components-filterchip--removable). Activate Remove My region and check that focus moves to Apply filter.
|
|
53
|
+
- [Select and remove separately](https://kbui.kcb.pro/storybook/?path=/story/components-filterchip--selectable-and-removable). Tab from the selection button to the remove button.
|
|
54
|
+
- [Disabled chip](https://kbui.kcb.pro/storybook/?path=/story/components-filterchip--disabled). Check that the disabled buttons stay out of the Tab order.
|
|
55
|
+
|
|
56
|
+
## Reference
|
|
57
|
+
|
|
58
|
+
| Prop | Type | Default | Notes |
|
|
59
|
+
| --- | --- | --- | --- |
|
|
60
|
+
| `label` | `string` | required | Visible label and accessible name of the selection button |
|
|
61
|
+
| `selected` | `boolean` | unset | Controlled pressed state. Required with `onSelectedChange` |
|
|
62
|
+
| `onSelectedChange` | `(selected: boolean) => void` | unset | Receives the next pressed state when selection is activated |
|
|
63
|
+
| `onRemove` | `() => void` | unset | Renders the remove button and runs when it is activated |
|
|
64
|
+
| `removeLabel` | `string` | `Remove ${label}` | Localize the remove button name or include context when labels repeat |
|
|
65
|
+
| `disabled` | `boolean` | `false` | Disables both available buttons |
|
|
66
|
+
| `classNames` | `ClassNames<FilterChipSlot>` | unset | Keys are `root`, `label`, `select`, `indicator`, and `remove` |
|
|
67
|
+
|
|
68
|
+
The `ref`, `id` and `style` apply to the outer `<span>`. Selection and removal use separate native buttons. The selection button exposes `aria-pressed`. The marker and remove icon stay out of the accessible name. Keep surrounding actions outside the chip. See [the accessibility guide](../../../../docs/guides/accessibility.md) for verification steps.
|
|
69
|
+
|
|
70
|
+
Selected chips use a tint and checkmark. If both actions are present, a divider marks the removal target. On coarse pointers, each action gets a larger target.
|
|
71
|
+
|
|
72
|
+
## Related components
|
|
73
|
+
|
|
74
|
+
Use [`Badge`](Badge.md) for static metadata, [`ToggleButton`](ToggleButton.md) for a pressed action such as bold formatting, and [`MultiSelect`](MultiSelect.md) for a field that collects multiple options from a list.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# ToggleButton
|
|
2
|
+
|
|
3
|
+
Use a pressed button for a view option or an action that stays active until the user presses the same button again.
|
|
4
|
+
|
|
5
|
+
[All components](../../README.md#components) · [Usage](#usage) · [Examples](#more-examples) · [Reference](#reference) · [Live examples and accessibility](https://kbui.kcb.pro/storybook/?path=/docs/components-togglebutton--docs)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import "@kb.ui/react/styles.css";
|
|
11
|
+
import { ToggleButton } from "@kb.ui/react";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
|
|
14
|
+
export function Example() {
|
|
15
|
+
const [showGrid, setShowGrid] = useState(true);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ToggleButton pressed={showGrid} onPressedChange={setShowGrid}>
|
|
19
|
+
Show grid
|
|
20
|
+
</ToggleButton>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## More examples
|
|
26
|
+
|
|
27
|
+
- [Standalone toggle](https://kbui.kcb.pro/storybook/?path=/story/components-togglebutton--default) demonstrates native keyboard activation.
|
|
28
|
+
- [Controlled state](https://kbui.kcb.pro/storybook/?path=/story/components-togglebutton--controlled) keeps the pressed state with the surrounding interface.
|
|
29
|
+
- [Disabled and pressed](https://kbui.kcb.pro/storybook/?path=/story/components-togglebutton--disabled) shows a current state while preventing edits.
|
|
30
|
+
|
|
31
|
+
## Reference
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Notes |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| `children` | `ReactNode` | | Visible label or decorative icon content |
|
|
36
|
+
| `pressed` | `boolean` | | Controlled pressed state |
|
|
37
|
+
| `defaultPressed` | `boolean` | `false` | Initial uncontrolled pressed state |
|
|
38
|
+
| `onPressedChange` | `(pressed, eventDetails) => void` | | Receives the proposed state and Base UI change details |
|
|
39
|
+
| `disabled` | `boolean` | `false` | Prevents interaction |
|
|
40
|
+
| `value` | `string` | | Unique nonempty identifier within a `ToggleGroup` |
|
|
41
|
+
| `aria-label` / `aria-labelledby` | `string` | | Accessible name when the button has no visible text |
|
|
42
|
+
| `className` | `string` | | Extra class on the button |
|
|
43
|
+
| `ref` | `Ref<HTMLButtonElement>` | | Reference to the underlying button |
|
|
44
|
+
|
|
45
|
+
Use the same name in both states so assistive technology can report the change through `aria-pressed`. The decorative checkmark marks the pressed state without changing the button width. When the toggle is in a `ToggleGroup`, set its `value` and let the group own the pressed state.
|
|
46
|
+
|
|
47
|
+
Pressed buttons pair a tinted surface with an accent border and checkmark. The checkmark and surface feedback settle quickly and switch instantly under reduced motion.
|
|
48
|
+
|
|
49
|
+
The component renders a native `<button type="button">`. Style it through `className` or CSS tokens and give it a label through `children` or an accessible naming prop. Pressing it inside a form leaves submission to the form's submit controls. Check the name and pressed state in the accessibility tree, then use Tab, Enter and Space to verify focus and activation.
|
|
50
|
+
|
|
51
|
+
## Related components
|
|
52
|
+
|
|
53
|
+
Use [`ToggleGroup`](ToggleGroup.md) for several independent pressed options, [`Button`](Button.md) for a one-time action, or [`Switch`](Switch.md) for an on/off setting.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# ToggleGroup
|
|
2
|
+
|
|
3
|
+
Group independently pressed buttons under one accessible name. Each button keeps its own pressed state as users move between choices.
|
|
4
|
+
|
|
5
|
+
[All components](../../README.md#components) · [Usage](#usage) · [Examples](#more-examples) · [Reference](#reference) · [Live examples and accessibility](https://kbui.kcb.pro/storybook/?path=/docs/components-togglegroup--docs)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import "@kb.ui/react/styles.css";
|
|
11
|
+
import { ToggleButton, ToggleGroup } from "@kb.ui/react";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
|
|
14
|
+
type Layer = "roads" | "water" | "labels";
|
|
15
|
+
|
|
16
|
+
export function Example() {
|
|
17
|
+
const [visibleLayers, setVisibleLayers] = useState<Layer[]>(["roads"]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ToggleGroup aria-label="Map layers" value={visibleLayers} onValueChange={setVisibleLayers}>
|
|
21
|
+
<ToggleButton value="roads">Roads</ToggleButton>
|
|
22
|
+
<ToggleButton value="water">Water</ToggleButton>
|
|
23
|
+
<ToggleButton value="labels">Place labels</ToggleButton>
|
|
24
|
+
</ToggleGroup>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## More examples
|
|
30
|
+
|
|
31
|
+
- [Text formatting](https://kbui.kcb.pro/storybook/?path=/story/components-togglegroup--default) lets users toggle formatting options independently.
|
|
32
|
+
- [Vertical layers](https://kbui.kcb.pro/storybook/?path=/story/components-togglegroup--vertical) uses Up and Down and stops at the ends.
|
|
33
|
+
|
|
34
|
+
## Reference
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Notes |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| `children` | `ReactNode` | | Place a `ToggleButton` with a unique nonempty `value` for each choice |
|
|
39
|
+
| `value` | `readonly string[]` | | Controlled values of all pressed buttons |
|
|
40
|
+
| `defaultValue` | `readonly string[]` | `[]` | Initial uncontrolled values |
|
|
41
|
+
| `onValueChange` | `(value, eventDetails) => void` | | Receives all proposed pressed values and Base UI change details |
|
|
42
|
+
| `aria-label` / `aria-labelledby` | `string` | | Accessible group name |
|
|
43
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Horizontal rows wrap as space runs out. Vertical groups stack |
|
|
44
|
+
| `loopFocus` | `boolean` | `true` | Wraps arrow-key focus at the first and last choices |
|
|
45
|
+
| `disabled` | `boolean` | `false` | Disables every member |
|
|
46
|
+
| `className` | `string` | | Extra class on the group |
|
|
47
|
+
| `ref` | `Ref<HTMLDivElement>` | | Reference to the underlying group |
|
|
48
|
+
|
|
49
|
+
The root renders a `<div role="group">`. Tab enters a standalone group once. Left and Right follow the visual order in horizontal groups, including when `dir="rtl"` is inherited. Use Up and Down in vertical groups. Home and End reach the first and last available button in standalone groups. Space and Enter toggle the focused button. Disabled or hidden items are skipped. When the group is inside a `Toolbar`, the toolbar owns the shared Tab stop and arrow navigation.
|
|
50
|
+
|
|
51
|
+
Give the group and each button a clear name. Check that arrow keys move focus while leaving the pressed values intact.
|
|
52
|
+
|
|
53
|
+
Set controlled state on `ToggleGroup`. Group values can be empty and can contain multiple options. Supply the application’s form fields separately when pressed values need to submit with a form.
|
|
54
|
+
|
|
55
|
+
The recessed group frame is shared by both orientations. Pressed options have their own tinted fill and checkmark, so several choices can remain visible at once.
|
|
56
|
+
|
|
57
|
+
## Related components
|
|
58
|
+
|
|
59
|
+
Use [`RadioGroup`](RadioGroup.md) for one choice from a set, [`ToggleButton`](ToggleButton.md) for a single pressed option, or [`Toolbar`](Toolbar.md) for a group of actions.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# TreeList
|
|
2
|
+
|
|
3
|
+
Show folders, topics, or categories as a hierarchy of native lists. Branches expand and collapse with a short height transition and a rotating chevron. Connector rails clarify the visible grouping.
|
|
4
|
+
|
|
5
|
+
[All components](../../README.md#components) · [Usage](#usage) · [Reference](#reference) · [Live examples and accessibility](https://kbui.kcb.pro/storybook/?path=/docs/components-treelist--docs)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import "@kb.ui/react/styles.css";
|
|
11
|
+
import { TreeList, type TreeListItem } from "@kb.ui/react";
|
|
12
|
+
|
|
13
|
+
const items: readonly TreeListItem[] = [
|
|
14
|
+
{
|
|
15
|
+
id: "workspace",
|
|
16
|
+
label: "Workspace setup",
|
|
17
|
+
children: [
|
|
18
|
+
{ id: "profile", label: <a href="/guide/profile">Profile</a> },
|
|
19
|
+
{
|
|
20
|
+
id: "access",
|
|
21
|
+
label: "Access",
|
|
22
|
+
children: [{ id: "roles", label: <a href="/guide/roles">Team roles</a> }],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{ id: "help", label: <a href="/guide/help">Getting help</a> },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export function GuideTopics() {
|
|
30
|
+
return <TreeList aria-label="Guide topics" items={items} defaultExpandedIds={["workspace"]} />;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## More examples
|
|
35
|
+
|
|
36
|
+
- [Controlled](https://kbui.kcb.pro/storybook/?path=/story/components-treelist--controlled) shows application-owned expansion in a runbook.
|
|
37
|
+
- [Depth cap](https://kbui.kcb.pro/storybook/?path=/story/components-treelist--depth-cap) shows how deep branches remain reachable in a shallow visual layout.
|
|
38
|
+
- [Formatted labels](https://kbui.kcb.pro/storybook/?path=/story/components-treelist--formatted-labels) shows inline emphasis, highlighted text, and longer branch names.
|
|
39
|
+
|
|
40
|
+
## Reference
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Default | Purpose |
|
|
43
|
+
|---|---|---|---|
|
|
44
|
+
| `items` | `readonly TreeListItem[]` | Required | Items in display order. Each item has a unique stable `id`, a React `label`, and optional `children`. An item with no children is a leaf. |
|
|
45
|
+
| `expandedIds` | `readonly string[]` | — | Controls which branches are expanded. |
|
|
46
|
+
| `defaultExpandedIds` | `readonly string[]` | `[]` | Applies initial expansion in uncontrolled use. |
|
|
47
|
+
| `onExpandedChange` | `(ids: string[]) => void` | — | Receives the requested branch IDs after a toggle. Descendant expansion is retained when an ancestor closes. |
|
|
48
|
+
| `maxVisualDepth` | `number` | `4` | Number of indented child levels below the root. Zero removes indentation and rails. Negative values become zero, fractions round down, and non-finite values use the default. |
|
|
49
|
+
| `classNames` | `ClassNames<"root" \| "item" \| "trigger" \| "label" \| "branch">` | — | Adds classes to the outer list, items, branch buttons, labels, and nested lists. |
|
|
50
|
+
| `aria-label` / `aria-labelledby`, `className`, `ref` | Native `ul` props | — | Names, styles, or references the outer list. |
|
|
51
|
+
|
|
52
|
+
After the indentation cap, the component keeps rendering nested child lists at the same visual depth. Each branch still expands independently. Collapsed descendants stay mounted and are hidden from navigation. Keep IDs stable across renders to preserve expansion for the same entries. Choose short, descriptive branch labels and use noninteractive inline content inside each branch button. Place links at leaves.
|
|
53
|
+
|
|
54
|
+
Use `<strong>` for emphasis and `<mark>` to highlight a relevant phrase within a label. TreeList keeps the phrase in the text flow and styles the highlight with the current theme.
|
|
55
|
+
|
|
56
|
+
Tab and Shift+Tab navigate visible branch buttons and leaf links. Enter and Space toggle a focused branch button and keep focus on it. Pointer collapse returns focus to the branch button if it would hide the focused descendant. If the application closes a branch through a separate controlled update while one of its descendants has focus, move focus to a visible control as part of that update. Verify that every branch exposes the expected name and expanded state, and that nested links are skipped while their branch is closed.
|
|
57
|
+
|
|
58
|
+
Collapsing a branch immediately removes its descendants from keyboard and assistive-technology navigation. Reduced motion makes expansion and collapse instant.
|
|
59
|
+
|
|
60
|
+
Use `--kb-treelist-indent`, `--kb-treelist-rail`, `--kb-treelist-row-height`, and `--kb-treelist-hover-background` to style spacing, rails, and row highlights. Use `--kb-treelist-motion-duration` and `--kb-treelist-motion-easing` to adjust branch and chevron motion. They default to kbui’s 160 ms duration and standard easing. Preserve readable text, visible focus, and a clear branch indicator when overriding tokens. See [Implementing and verifying accessibility](../../../../docs/guides/accessibility.md) for keyboard, assistive technology, and visual verification.
|
|
61
|
+
|
|
62
|
+
## Related components
|
|
63
|
+
|
|
64
|
+
Use [CollectionList](CollectionList.md) for a flat list of peer records, [Disclosure](Disclosure.md) for a single expandable block, or [Accordion](Accordion.md) for related sections with headings and panels.
|