---
title: "Tree Select"
description: "Pick many values from a tree, such as countries and cities. Branches open in place, a parent shows a dash when partly picked, and search keeps the path."
url: https://gelatinui.com/components/tree-select
markdown_url: https://gelatinui.com/components/tree-select.md
access: free
install: "npx shadcn@latest add @gelatin-ui/tree-select"
registry_item: https://gelatinui.com/r/tree-select.json
version: "2026-11-17"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Tree Select

> Pick many values from a tree, such as countries and cities. Branches open in place, a parent shows a dash when partly picked, and search keeps the path.

Page: https://gelatinui.com/components/tree-select

## When to use it

Best for: Picking many values from a tree in a field, with checks on parents and search over every level.

- Use it when the options form a tree and people pick many leaves, or whole branches at once.
- Use `store="compact"` to save a full branch as one value, so new children join the pick.
- Use `multiple={false}` to pick one leaf: the field then shows its path, such as Audio / Turntables.
- Use `getChildren` to load the rows of a branch when it opens.

## When not to use it

- To pick a value one level at a time, or in columns, use a [Cascader](https://gelatinui.com/components/cascader.md).
- For a flat list with search, use a [Combobox](https://gelatinui.com/components/combobox.md).
- For a tree that stays open on the page, use a [Tree](https://gelatinui.com/components/tree.md).
- To move many items between two lists, use a [Transfer List](https://gelatinui.com/components/transfer-list.md).

## Notes for agents

- `value` and `onValueChange` always use a `string[]`, also with `multiple={false}`.
- Each node of `items` has `value`, `label`, and optional `children`, `count`, `keywords`, `disabled`, `disabledReason`, and `hasChildren`.
- With `store="leaves"` (the default) the value holds only leaves. With `store="compact"` a full branch is one value.
- Compose `TreeSelect` with `TreeSelectTrigger` and `TreeSelectContent`. Put `TreeSelectSearch`, `TreeSelectTree`, and `TreeSelectFooter` in the content.
- `TreeSelectTrigger` has no visible label: give it `aria-label`, or put it in a `Field` with a `FieldLabel` and pass `aria-labelledby`.
- Pass `name` to send the value with a form: one entry per value.
- A branch with `hasChildren` and no `children` calls `getChildren` when it opens. A failed load shows Did not load with Retry.
- From 120 rows the tree draws only the rows in view.

## Anatomy

```text
TreeSelect
├─ TreeSelectTrigger (0..n)
├─ TreeSelectContent (0..n)
├─ TreeSelectSearch (0..n)
├─ TreeSelectExpandAll (0..n)
├─ TreeSelectTree (0..n)
├─ TreeSelectFooter (0..n)
├─ TreeSelectCount (0..n)
├─ TreeSelectClear (0..n)
└─ TreeSelectDone (0..n)
```

## API reference

### TreeSelect

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `readonly CascaderNode[]` |  | The tree: each node has `value`, `label`, and optional `children`, `count`, `disabled`, `disabledReason`, `hasChildren`. |
| `value` | `readonly string[]` |  | The picked values. With `store="leaves"` (default) only leaves; with `store="compact"` a full branch is its own value ("watches" for all 5 watches), so new children join it. |
| `defaultValue` | `readonly string[]` |  |  |
| `onValueChange` | `function` |  |  |
| `multiple` | `boolean` | true | Pick many (checkboxes, chips) or one (no boxes, the path in the trigger). Default `true`. |
| `store` | `"compact" \| "leaves"` | "leaves" | How the value names a full branch: each leaf (`leaves`), or the branch (`compact`). |
| `getChildren` | `function` |  | Loads the rows of a branch with `hasChildren` and no `children`, when it opens. |
| `open` | `boolean` |  |  |
| `defaultOpen` | `boolean` | false |  |
| `onOpenChange` | `function` |  |  |
| `disabled` | `boolean` | false |  |
| `readOnly` | `boolean` | false |  |
| `invalid` | `boolean` | false |  |
| `name` | `string` |  | The field name the form sends: one entry per value. |
| `size` | `"default" \| "lg"` | "default" | The trigger row: `default` 32px with 24px chips, `lg` 36px with 28px chips. |
| `locale` | `string` |  | The search locale. Default: the `DisplayLocaleProvider` locale, else `en-US`. |
| `labels` | `Partial<typeof TREE_SELECT_LABELS>` |  |  |
| `className` | `string` |  | Classes of the root box (its width). |
| `children` | `ReactNode` |  |  |

### TreeSelectTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. Names the field ("Applies to"): the trigger has no visible label of its own. |
| `aria-labelledby` | `string` |  | Identifies the element (or elements) that labels the current element. |
| `placeholder` | `string` |  | The muted text while nothing is picked. |
| `maxChips` | `number` | 3 | The chips that show before the rest fold into "+N". Default 3. |

### TreeSelectContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `arrow` | `boolean` |  | Show an arrow that points at the trigger. The gap grows from 4px to 8px. |
| `backdrop` | `boolean` |  | Put a clear layer under the popup (Base UI `Popover.Backdrop`), for example to dim it. |
| `padding` | `"default" \| "none" \| "tight"` |  | `default`: radius 14, 12px padding and 10px between the parts, 288px wide. `tight`: 4px padding and 4px between the parts, as wide as the content: a row of 28px actions (a plain Toolbar) with the 4px inset of the bar recipe, 38px high (the selection pill of the Quote Reply). `none`: no padding and no gap, as wide as the content: a panel that lays out its own parts edge to edge (a head with a rule, a scroll box, a docked composer: the Chat Popup). Give it a width and a height with layout classes; the body fills that height. |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `positionerProps` | `PopupPartProps` |  |  |
| `backdropProps` | `PopupPartProps<PopoverBackdropProps>` |  |  |
| `arrowProps` | `PopupPartProps<PopoverArrowProps>` |  |  |
| `closeButtonProps` | `PopupPartProps` |  |  |

Also takes every prop of Base UI `Popover.Portal`: https://base-ui.com/react/components/popover

### TreeSelectSearch

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | Things at the end of the row, after the clear button: `TreeSelectExpandAll`. |

### TreeSelectExpandAll

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### TreeSelectTree

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Names the tree ("Categories"). |
| `className` | `string` |  |  |
| `renderIcon` | `function` |  | A mark before a row label: an icon per node (a folder, a flag). |

### TreeSelectFooter

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TreeSelectCount

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TreeSelectClear

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### TreeSelectDone

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` |  |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TreeSelect | `tree-select` |  |  |  |
| TreeSelectTrigger | `tree-select-trigger` | `data-empty`, `data-part`, `data-plain`, `data-popup-open`, `data-stage-focused` |  |  |
| TreeSelectContent | `tree-select-content` |  | `--anchor-width` |  |
| TreeSelectSearch | `tree-select-search` |  |  |  |
| TreeSelectExpandAll | `tree-select-expand-all` |  |  |  |
| TreeSelectTree | `tree-select-tree` |  |  |  |
| TreeSelectFooter | `tree-select-footer` |  |  |  |
| TreeSelectCount | `tree-select-count` |  |  |  |
| TreeSelectClear | `tree-select-clear` |  |  |  |
| TreeSelectDone | `tree-select-done` |  |  |  |

## Usage

Pass the tree as `items`. Each node has a `value`, a `label`, and optional `children`. The value is always a `string[]`.

```tsx title="category-picker.tsx"
import {
  TreeSelect,
  TreeSelectClear,
  TreeSelectContent,
  TreeSelectCount,
  TreeSelectDone,
  TreeSelectFooter,
  TreeSelectSearch,
  TreeSelectTree,
  TreeSelectTrigger,
} from "@/components/ui/tree-select";

const CATEGORIES = [
  {
    value: "audio",
    label: "Audio",
    children: [
      { value: "headphones", label: "Headphones" },
      { value: "speakers", label: "Speakers" },
    ],
  },
  { value: "watches", label: "Watches", children: [{ value: "dive", label: "Dive watches" }] },
];

export function CategoryPicker() {
  return (
    <TreeSelect items={CATEGORIES} defaultValue={["headphones"]} name="categories">
      <TreeSelectTrigger aria-label="Applies to" placeholder="Pick categories" />
      <TreeSelectContent>
        <TreeSelectSearch placeholder="Search categories" />
        <TreeSelectTree aria-label="Categories" />
        <TreeSelectFooter>
          <TreeSelectCount />
          <TreeSelectClear />
          <TreeSelectDone />
        </TreeSelectFooter>
      </TreeSelectContent>
    </TreeSelect>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/tree-select
```

It adds 63 registry items: 60 files, 10303 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Collapsible](https://gelatinui.com/components/collapsible.md)
- [Highlight](https://gelatinui.com/components/highlight.md)
- [Popover](https://gelatinui.com/components/popover.md)
- [Tag Group](https://gelatinui.com/components/tag-group.md)
- [Tree](https://gelatinui.com/components/tree.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Cascader](https://gelatinui.com/components/cascader.md)
- [Tree](https://gelatinui.com/components/tree.md)
- [Combobox](https://gelatinui.com/components/combobox.md)
- [Tag Group](https://gelatinui.com/components/tag-group.md)
- [Popover](https://gelatinui.com/components/popover.md)
- [Transfer List](https://gelatinui.com/components/transfer-list.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | On the field, opens the popup. Focus goes to the search. |
| Down Arrow | In the search, moves focus to the first row of the tree. |
| Up Arrow, Down Arrow | Moves between the rows. A disabled row is skipped. |
| Right Arrow, Left Arrow | Opens or closes the branch of the row. Right to left swaps them. |
| Space | Checks or clears the row. On a parent, it checks or clears every leaf under it. |
| Backspace | In an empty search, removes the last pick. |
| Escape | In the search, clears the text first. Then it closes the popup, and focus goes back to the field. |
| Tab | From the field, moves to the chips. Left Arrow and Right Arrow move between them. |
| Delete, Backspace | On a chip, removes the pick. A branch chip removes every leaf under it. |

## Accessibility

The field is a button that opens a dialog popup. The options are a tree grid with checkboxes, from React Aria.

A parent with some picks shows a dash (mixed), and with all picks a check.

A disabled row says why at its end, and the arrow keys skip it.

On a touch screen the rows are 44px high, and the search does not take focus, so no keyboard opens.

## Motion

| Part | Motion |
| --- | --- |
| Open | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · fades in and scales from 95% |
| Close | popup-exit · 120ms · ease-out (0, 0, 0.2, 1) |
| Chevron | panelBounce · the field chevron turns past its angle while the popup opens, then settles |
