Forms
TreeSelect
A select whose options are a tree: choose one leaf, or check several with tri-state branches. Optional search filters the tree.
import { TreeSelect } from '@reactloom/ui';Examples
Single
Choosing a leaf sets the value and closes the popover.
Team
import { TreeSelect } from '@reactloom/ui';
const departments = [
{ id: 'eng', label: 'Engineering', children: [{ id: 'web', label: 'Web' }, { id: 'mobile', label: 'Mobile' }, { id: 'platform', label: 'Platform' }] },
{ id: 'design', label: 'Design', children: [{ id: 'product-design', label: 'Product design' }, { id: 'brand', label: 'Brand' }] },
{ id: 'sales', label: 'Sales' },
];
export default function Example() {
return (
<div style={{ width: '100%', maxWidth: 320 }}>
<TreeSelect label="Team" nodes={departments} defaultValue="web" name="team" />
</div>
);
}Multiple with search
Checking a branch checks its leaves; partially checked branches show a mixed state.
Notify teams
import { TreeSelect } from '@reactloom/ui';
import { useState } from 'react';
const departments = [
{ id: 'eng', label: 'Engineering', children: [{ id: 'web', label: 'Web' }, { id: 'mobile', label: 'Mobile' }, { id: 'platform', label: 'Platform' }] },
{ id: 'design', label: 'Design', children: [{ id: 'product-design', label: 'Product design' }, { id: 'brand', label: 'Brand' }] },
{ id: 'sales', label: 'Sales' },
];
export default function Example() {
const [teams, setTeams] = useState<string[]>(['web', 'mobile']);
return (
<div style={{ width: '100%', maxWidth: 320 }}>
<TreeSelect label="Notify teams" nodes={departments} multiple searchable value={teams} onValueChange={setTeams} />
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
nodesrequiredAs on TreeView. | TreeViewNode[] | — |
multipleCheckbox selection. | boolean | false |
value / defaultValue | string | null (string[] when multiple) | — |
onValueChange | (value) => void | — |
searchable · searchLabelA search field that filters the tree. | boolean · string | false · 'Search' |
loadChildrenLazy branches. | (node) => Promise<TreeViewNode[]> | — |
nameOne hidden input per value. | string | — |
label · description · error · required · disabled · size · placeholderAs on Select. | | — |
classNames · stylesroot, label, description, trigger, value, indicator, popover, search, tree, error. | Partial<Record<TreeSelectSlot, …>> | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
Accessibility
- The trigger opens a dialog popover containing a labelled tree; focus returns to the trigger when it closes.
- Tree keys work as on TreeView; Space checks in multiple mode.
| Key | Action |
|---|---|
| Enter / Space | Open |
| ↑ ↓ → ← | Move through the tree |
| Enter | Choose a leaf (single) |
| Space | Check or uncheck (multiple) |
| Escape | Close |
Usage guidelines
Do
- Use for hierarchies such as departments, categories or folders.
Don’t
- Don’t use for flat lists; use Select or MultiSelect.