Examples

Single

Choosing a leaf sets the value and closes the popover.

Preview
Team
Example.tsx
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.

Preview
Notify teams
Example.tsx
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

TreeSelect props
PropTypeDefault
nodesrequired
As on TreeView.
TreeViewNode[]—
multiple
Checkbox selection.
booleanfalse
value / defaultValue
string | null (string[] when multiple)—
onValueChange
(value) => void—
searchable · searchLabel
A search field that filters the tree.
boolean · stringfalse · 'Search'
loadChildren
Lazy branches.
(node) => Promise<TreeViewNode[]>—
name
One hidden input per value.
string—
label · description · error · required · disabled · size · placeholder
As on Select.
—
classNames · styles
root, 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.
Keyboard interactions
KeyAction
Enter / SpaceOpen
↑ ↓ → ←Move through the tree
EnterChoose a leaf (single)
SpaceCheck or uncheck (multiple)
EscapeClose

Usage guidelines

Do

  • Use for hierarchies such as departments, categories or folders.

Don’t

  • Don’t use for flat lists; use Select or MultiSelect.