# TreeSelect
Package: @mantine/core
Import: import { TreeSelect } from '@mantine/core';
Description: Select with hierarchical tree data

## Usage

`TreeSelect` allows picking one or more values from hierarchical data:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
    />
  );
}
```


## TreeSelect with uncontrolled forms

Set `name` to submit node values rather than labels. In multiple and checkbox modes, values share one field; `hiddenInputValuesDivider` sets the separator:

```tsx
import { TreeSelect } from '@mantine/core';

function Demo() {
  return (
    <form
      onSubmit={(event) => {
        event.preventDefault();
        const data = new FormData(event.currentTarget);
        console.log(data.get('languages'));
      }}
    >
      <TreeSelect
        name="languages"
        label="Languages"
        mode="multiple"
        data={[
          { value: 'js', label: 'JavaScript' },
          { value: 'ts', label: 'TypeScript' },
        ]}
        defaultValue={['js', 'ts']}
      />
      <button type="submit">Submit</button>
    </form>
  );
}
```

## Virtualized dropdown

Use `virtualizer` to render only the visible tree rows. Expand or collapse a category to change which products appear:

```tsx
import { TreeSelect } from '@mantine/core';
import { catalog } from './data';
import { VirtualList } from './VirtualList';

function Demo() {
  return (
    <TreeSelect
      label="Browse the catalog"
      placeholder="Choose a product"
      data={catalog}
      defaultExpandAll
      virtualizer={VirtualList}
    />
  );
}
```


## Data prop

Data passed to the `data` prop must follow the same rules as the [Tree](https://alpha.mantine.dev/llms/core-tree.md) component:

* Data must be an array of `TreeNodeData` objects
* Each node must have `value` and `label` keys, `value` must be unique
* Each node can have a `children` key with an array of child nodes

```tsx
import { TreeNodeData } from '@mantine/core';

const data: TreeNodeData[] = [
  {
    value: 'fruits',
    label: 'Fruits',
    children: [
      { value: 'apple', label: 'Apple' },
      { value: 'banana', label: 'Banana' },
    ],
  },
  { value: 'milk', label: 'Milk' },
];
```

## Selection modes

Use the `mode` prop to change the selection mode:

* `single` (default) – single value selection, renders as an input
* `multiple` – multiple value selection, renders as pills
* `checkbox` – checkbox selection with parent-child cascade, renders as pills

### Multiple mode

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite items"
      placeholder="Pick values"
      data={data}
      mode="multiple"
      defaultExpandAll
    />
  );
}
```


### Checkbox mode

In checkbox mode, checking or unchecking a parent node does the same for all its children.
If only some children are checked, the parent is displayed in indeterminate state:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Select categories"
      placeholder="Pick values"
      data={data}
      mode="checkbox"
      defaultExpandAll
    />
  );
}
```


## Controlled

```tsx
import { useState } from 'react';
import { TreeSelect } from '@mantine/core';

// Single mode
function SingleDemo() {
  const [value, setValue] = useState<string | null>(null);
  return <TreeSelect data={[]} value={value} onChange={setValue} />;
}

// Multiple or checkbox mode
function MultipleDemo() {
  const [value, setValue] = useState<string[]>([]);
  return <TreeSelect data={[]} mode="multiple" value={value} onChange={setValue} />;
}
```

## Searchable

Set `searchable` prop to allow filtering options by user input.
Matching nodes are displayed together with their ancestors:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      searchable
    />
  );
}
```


## Nothing found

Set `nothingFoundMessage` prop to display a message when no options match the search query
or there is no data:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      searchable
      nothingFoundMessage="Nothing found..."
    />
  );
}
```


## Clearable

Set the `clearable` prop to display the clear button in the right section:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      defaultValue="iphone"
      defaultExpandedValues={['electronics', 'phones']}
      clearable
    />
  );
}
```


## Expand on click

Set `expandOnClick` prop to expand and collapse a parent node when it is clicked, not only with the chevron.
In checkbox mode, the click also toggles the checked state:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      expandOnClick
    />
  );
}
```


## Connecting lines

`TreeSelect` renders connecting lines between parent and child nodes by default.
Set `withLines={false}` to disable them:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Without connecting lines"
      placeholder="Pick value"
      data={data}
      defaultExpandAll
      withLines={false}
    />
  );
}
```


## Check strictly

Set `checkStrictly` to disable parent-child cascade in checkbox mode, each node is checked independently:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Select items"
      placeholder="Pick values"
      data={data}
      mode="checkbox"
      checkStrictly
      defaultExpandAll
    />
  );
}
```


## Checked strategy

`checkedStrategy` prop controls which checked nodes appear in the value and pills in checkbox mode:

* `child` (default) – only leaf nodes appear in the value
* `all` – all checked nodes (parents and children) appear in the value
* `parent` – only the topmost fully-checked parents appear in the value

```tsx
import { useState } from 'react';
import { Stack, TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  const [childValue, setChildValue] = useState<string[]>([]);
  const [allValue, setAllValue] = useState<string[]>([]);
  const [parentValue, setParentValue] = useState<string[]>([]);

  return (
    <Stack>
      <TreeSelect
        label="checkedStrategy: child (default)"
        placeholder="Pick values"
        data={data}
        mode="checkbox"
        checkedStrategy="child"
        defaultExpandAll
        value={childValue}
        onChange={setChildValue}
      />
      <TreeSelect
        label="checkedStrategy: all"
        placeholder="Pick values"
        data={data}
        mode="checkbox"
        checkedStrategy="all"
        defaultExpandAll
        value={allValue}
        onChange={setAllValue}
      />
      <TreeSelect
        label="checkedStrategy: parent"
        placeholder="Pick values"
        data={data}
        mode="checkbox"
        checkedStrategy="parent"
        defaultExpandAll
        value={parentValue}
        onChange={setParentValue}
      />
    </Stack>
  );
}
```


## Max values

Set `maxValues` prop to limit the number of selected values in multiple and checkbox modes:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Pick up to 3 items"
      placeholder="Pick values"
      data={data}
      mode="multiple"
      maxValues={3}
      defaultExpandAll
    />
  );
}
```


## renderNode

Use `renderNode` callback to customize node rendering in the dropdown:

```tsx
import { FileTextIcon, FolderOpenIcon, FolderSimpleIcon } from '@phosphor-icons/react';
import { Group, Text, TreeSelect, TreeSelectProps } from '@mantine/core';
import { data } from './data';

const renderTreeNode: TreeSelectProps['renderNode'] = ({ node, hasChildren, expanded }) => (
  <Group gap="xs">
    {hasChildren ? (
      expanded ? (
        <FolderOpenIcon color="var(--mantine-color-yellow-7)" size={16} />
      ) : (
        <FolderSimpleIcon color="var(--mantine-color-yellow-7)" size={16} />
      )
    ) : (
      <FileTextIcon size={16} />
    )}
    <Text size="sm">{node.label}</Text>
  </Group>
);

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      renderNode={renderTreeNode}
      defaultExpandAll
    />
  );
}
```


The payload includes an `expand` function that toggles the node. Use it to build a custom
expand control, set `expandOnClick={false}` to expand nodes only with your control:

```tsx
import { CaretRightIcon } from '@phosphor-icons/react';
import { Group, TreeSelect, TreeSelectProps } from '@mantine/core';
import { data } from './data';

const renderTreeNode: TreeSelectProps['renderNode'] = ({ node, hasChildren, expanded, expand }) => (
  <Group gap="xs" wrap="nowrap">
    {hasChildren ? (
      <CaretRightIcon
        size={14}
        onClick={expand}
        style={{
          cursor: 'pointer',
          transform: expanded ? 'rotate(90deg)' : undefined,
          transition: 'transform 150ms ease',
        }}
      />
    ) : (
      <span style={{ display: 'inline-block', width: 14 }} />
    )}
    <span>{node.label}</span>
  </Group>
);

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      renderNode={renderTreeNode}
      expandOnClick={false}
    />
  );
}
```


## renderPill

Use `renderPill` callback to customize pills of selected values in multiple and
checkbox modes. Call `onRemove` from your pill to remove the value.
The overflow pill is customized with `maxDisplayedValuesContent` instead:

```tsx
import { FileTextIcon, FolderSimpleIcon } from '@phosphor-icons/react';
import { Group, Pill, TreeSelect, TreeSelectProps } from '@mantine/core';
import { data } from './data';

const renderTreePill: TreeSelectProps['renderPill'] = ({ node, onRemove, disabled, readOnly }) => (
  <Pill withRemoveButton={!readOnly} onRemove={onRemove} disabled={disabled}>
    <Group gap={4} wrap="nowrap">
      {node.children || node.hasChildren ? (
        <FolderSimpleIcon size={12} />
      ) : (
        <FileTextIcon size={12} />
      )}
      {node.label}
    </Group>
  </Pill>
);

function Demo() {
  return (
    <TreeSelect
      mode="checkbox"
      checkedStrategy="parent"
      label="Categories"
      placeholder="Pick categories"
      data={data}
      defaultValue={['phones', 'headphones']}
      defaultExpandAll
      renderPill={renderTreePill}
    />
  );
}
```


## Scrollable dropdown

The options list is wrapped with [ScrollArea.Autosize](https://alpha.mantine.dev/llms/core-scroll-area.md), set `maxDropdownHeight` prop
to change the dropdown max-height:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      defaultExpandAll
      maxDropdownHeight={200}
    />
  );
}
```


## Control dropdown opened state

Use `dropdownOpened` prop to control the dropdown opened state, `onDropdownOpen` and `onDropdownClose`
to listen to its changes:

```tsx
import { TreeSelect, Button } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { data } from './data';

function Demo() {
  const [dropdownOpened, { toggle }] = useDisclosure();
  return (
    <>
      <Button onClick={toggle} mb="md">
        Toggle dropdown
      </Button>

      <TreeSelect
        label="Your favorite item"
        placeholder="Pick value"
        data={data}
        dropdownOpened={dropdownOpened}
      />
    </>
  );
}
```


## Dropdown position

By default, the dropdown is displayed below the input if there is enough space, otherwise above it.
Set `position` and `middlewares` props to change this behavior, they are passed down to
the underlying [Popover](https://alpha.mantine.dev/llms/core-popover.md). Example of a dropdown that is always displayed above the input:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      comboboxProps={{ position: 'top', middlewares: { flip: false, shift: false } }}
    />
  );
}
```


## Dropdown width

By default, the dropdown width is equal to the input width. Set `width` in `comboboxProps` to change it:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      comboboxProps={{ width: 200, position: 'bottom-start' }}
    />
  );
}
```


## Dropdown offset

Set `offset` in `comboboxProps` to change the dropdown offset:

```tsx
// Demo.tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';
import classes from './Demo.module.css';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      classNames={classes}
      comboboxProps={{ position: 'bottom', middlewares: { flip: false, shift: false }, offset: 0 }}
    />
  );
}

// Demo.module.css
.dropdown {
  border-top-right-radius: 0;
  border-top-left-radius: 0;
  border-color: light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4));
  border-top: 0;
}

.input {
  transition: none;

  &[data-expanded] {
    border-color: light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4));
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}
```


## Dropdown animation

By default, dropdown animations are disabled. Set `transitionProps` to enable them,
they are passed down to the underlying [Transition](https://alpha.mantine.dev/llms/core-transition.md) component:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      comboboxProps={{ transitionProps: { transition: 'pop', duration: 200 } }}
    />
  );
}
```


## Dropdown padding

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <>
      <TreeSelect
        label="Zero padding"
        placeholder="Pick value"
        data={data}
        comboboxProps={{ dropdownPadding: 0 }}
      />
      <TreeSelect
        mt="md"
        label="10px padding"
        placeholder="Pick value"
        data={data}
        comboboxProps={{ dropdownPadding: 10 }}
      />
    </>
  );
}
```


## Dropdown shadow

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      comboboxProps={{ shadow: 'md' }}
    />
  );
}
```


## Keyboard navigation

`TreeSelect` supports the following keyboard interactions when the dropdown is open:

* `ArrowRight` – expand the highlighted parent node
* `ArrowLeft` – collapse the highlighted parent node, or move to its parent
* `ArrowUp` / `ArrowDown` – move between options
* `Enter` – select the highlighted option

## Expand state

Use `defaultExpandedValues`, `defaultExpandAll` or `expandedValues` with `onExpandedChange` to manage expanded nodes:

```tsx
import { TreeSelect } from '@mantine/core';

// Expand specific nodes by default
<TreeSelect data={data} defaultExpandedValues={['fruits', 'vegetables']} />

// Expand all nodes by default
<TreeSelect data={data} defaultExpandAll />

// Controlled expanded state
<TreeSelect
  data={data}
  expandedValues={expandedValues}
  onExpandedChange={setExpandedValues}
/>
```

## Input sections

TreeSelect supports left and right sections to display icons, buttons or other content alongside the input.

```tsx
import { TreeSelect } from '@mantine/core';
import { SquaresFourIcon } from '@phosphor-icons/react';
import { data } from './data';

function Demo() {
  const icon = <SquaresFourIcon size={16} />;
  return (
    <>
      <TreeSelect
        data={data}
        leftSectionPointerEvents="none"
        leftSection={icon}
        label="Your favorite item"
        placeholder="Your favorite item"
      />
      <TreeSelect
        mt="md"
        data={data}
        rightSectionPointerEvents="none"
        rightSection={icon}
        label="Your favorite item"
        placeholder="Your favorite item"
      />
    </>
  );
}
```


## Input props

TreeSelect component supports [Input](https://mantine.dev/core/input) and [Input.Wrapper](https://mantine.dev/core/input) components features and all input element props. TreeSelect documentation does not include all features supported by the component – see [Input](https://mantine.dev/core/input) documentation to learn about all available features.

```tsx
// Demo.tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';


function Demo() {
  return (
    <TreeSelect
       variant="default" size="sm" radius="md" label="Input label" withAsterisk={false} description="Input description" error=""
      placeholder="Pick value"
      data={data}
    />
  );
}

// data.ts
import { TreeNodeData } from '@mantine/core';

export const data: TreeNodeData[] = [
  {
    value: 'electronics',
    label: 'Electronics',
    children: [
      {
        value: 'phones',
        label: 'Phones',
        children: [
          { value: 'iphone', label: 'iPhone' },
          { value: 'samsung', label: 'Samsung Galaxy' },
          { value: 'pixel', label: 'Google Pixel' },
        ],
      },
      {
        value: 'laptops',
        label: 'Laptops',
        children: [
          { value: 'macbook', label: 'MacBook' },
          { value: 'thinkpad', label: 'ThinkPad' },
        ],
      },
      { value: 'headphones', label: 'Headphones' },
    ],
  },
  {
    value: 'groceries',
    label: 'Groceries',
    children: [
      {
        value: 'fruits',
        label: 'Fruits',
        children: [
          { value: 'apples', label: 'Apples' },
          { value: 'bananas', label: 'Bananas' },
        ],
      },
      {
        value: 'vegetables',
        label: 'Vegetables',
        children: [
          { value: 'carrots', label: 'Carrots' },
          { value: 'broccoli', label: 'Broccoli' },
        ],
      },
    ],
  },
  { value: 'books', label: 'Books' },
  { value: 'toys', label: 'Toys' },
];
```


## Read only

Set `readOnly` to make the input read only, the dropdown is not displayed and `onChange` is not called:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      defaultValue="iphone"
      readOnly
    />
  );
}
```


## Disabled

Set `disabled` to disable the input:

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <TreeSelect
      label="Your favorite item"
      placeholder="Pick value"
      data={data}
      disabled
    />
  );
}
```


## Error state

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return (
    <>
      <TreeSelect
        label="Boolean error"
        placeholder="Boolean error"
        error
        data={data}
      />
      <TreeSelect
        mt="md"
        label="With error message"
        placeholder="With error message"
        error="Invalid value"
        data={data}
      />
    </>
  );
}
```


## Success state

```tsx
import { TreeSelect } from '@mantine/core';
import { data } from './data';

function Demo() {
  return <TreeSelect label="Tree Select" placeholder="Tree Select" data={data} success="Looks good!" />;
}
```


## Accessibility

TreeSelect provides better accessibility support when used in forms. Make sure to associate the input with a label for better screen reader support.

When `clearable` is set, use `clearButtonProps` to set `aria-label` on the clear button:

```tsx
import { TreeSelect } from '@mantine/core';

function Demo() {
  return (
    <TreeSelect
      data={[]}
      clearable
      clearButtonProps={{
        'aria-label': 'Clear input',
      }}
    />
  );
}
```


#### Props

**TreeSelect props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| allowDeselect | boolean | true | Allows deselecting in single mode |
| checkStrictly | boolean | false | Disables parent-child cascade in checkbox mode |
| checkedStrategy | CheckedStrategy | 'child' | Controls which checked nodes appear in value/pills in checkbox mode |
| chevronAriaLabels | TreeSelectChevronAriaLabels | - | aria-label values for the expand/collapse chevron button |
| chevronColor | MantineColor | - | Controls the default chevron color |
| clearButtonProps | InputClearButtonProps | - | Props for the clear button |
| clearSearchOnChange | boolean | true | Clear search on selection change |
| clearSectionMode | ClearSectionMode | 'both' | Determines how the clear button and rightSection are rendered |
| clearable | boolean | false | Shows clear button |
| comboboxProps | ComboboxProps | - | Props passed to the underlying Combobox |
| data | TreeNodeData[] | required | Tree data |
| defaultDropdownOpened | boolean | - | Default dropdown state |
| defaultExpandAll | boolean | false | Expand all nodes by default |
| defaultExpandedValues | string[] | - | Default expanded node values |
| defaultSearchValue | string | - | Default search value |
| defaultValue | string \| string[] \| null | - | Default value |
| description | React.ReactNode | - | Contents of `Input.Description` component. If not set, description is not displayed. |
| descriptionProps | InputDescriptionProps & DataAttributes & PlaceholderPolymorphicProps | - | Props passed down to the `Input.Description` component |
| disabled | boolean | - | Sets `disabled` attribute on the `input` element |
| dropdownOpened | boolean | - | Controlled dropdown state |
| error | React.ReactNode | - | Contents of `Input.Error` component. If not set, error is not displayed. |
| errorProps | InputErrorProps & DataAttributes & PlaceholderPolymorphicProps | - | Props passed down to the `Input.Error` component |
| expandOnClick | boolean | false | Also toggle expand when clicking a parent node (not just the chevron). In `single` and `multiple` modes, parent clicks only expand; only leaves can be selected. In `checkbox` mode, parent clicks both check and expand. |
| expandedValues | string[] | - | Controlled expanded state |
| filter | (query: string, node: TreeNodeData) => boolean | - | Custom filter function |
| hiddenInputProps | React.ComponentProps<"input"> | - | Props for the hidden input |
| hiddenInputValuesDivider | string | ',' | Divider for hidden input values |
| inputContainer | (children: ReactNode) => ReactNode | (children) => children | Render function to wrap the input element. Useful for adding tooltips, popovers, or other wrappers around the input. |
| inputSize | string | - | HTML `size` attribute for the input element (number of visible characters) |
| inputWrapperOrder | ("input" \| "label" \| "description" \| "error")[] | ['label', 'description', 'input', 'error'] | Controls order and visibility of wrapper elements. Only elements included in this array will be rendered. |
| label | React.ReactNode | - | Contents of `Input.Label` component. If not set, label is not displayed. |
| labelProps | InputLabelProps & DataAttributes & PlaceholderPolymorphicProps | - | Props passed down to the `Input.Label` component |
| leftSection | React.ReactNode | - | Content section displayed on the left side of the input |
| leftSectionPointerEvents | React.CSSProperties["pointerEvents"] | 'none' | Sets `pointer-events` styles on the `leftSection` element. Use `'all'` when section contains interactive elements (buttons, links). |
| leftSectionProps | React.ComponentProps<"div"> | - | Props passed down to the `leftSection` element |
| leftSectionWidth | React.CSSProperties["width"] | - | Left section width, used to set `width` of the section and input `padding-left`, by default equals to the input height |
| loaderProps | LoaderProps | - | Props passed down to the `Loader` component displayed when `loading` prop is set |
| loading | boolean | false | Displays loading indicator in the left or right section |
| loadingPosition | "left" \| "right" | 'right' | Position of the loading indicator |
| maxDisplayedValues | number | - | Maximum displayed pills before "+N more" |
| maxDisplayedValuesContent | ReactNode \| ((overflow: number) => ReactNode) | - | Content shown when values overflow maxDisplayedValues |
| maxDropdownHeight | string \| number | 220 | Max dropdown height |
| maxValues | number | - | Maximum selectable values (multiple/checkbox mode) |
| mode | TreeSelectMode | 'single' | Selection mode: 'single', 'multiple', or 'checkbox' (with cascade) |
| nothingFoundMessage | React.ReactNode | - | Message when no nodes match search |
| onChange | (value: TreeSelectValue<Mode>) => void | - | Called when value changes |
| onClear | () => void | - | Called when clear button is clicked |
| onDropdownClose | () => void | - | Called when dropdown closes |
| onDropdownOpen | () => void | - | Called when dropdown opens |
| onExpandedChange | (values: string[]) => void | - | Called when expanded state changes |
| onRemove | (value: string) => void | - | Called with removed value in multiple/checkbox mode |
| onSearchChange | (value: string) => void | - | Called when search changes |
| openOnFocus | boolean | true | Opens dropdown on focus (searchable mode) |
| pointer | boolean | false | Determines whether the input should use the theme cursor type. Use when input acts as a button-like trigger (e.g., `component="button"` for Select/DatePicker). |
| radius | MantineRadius \| number | theme.defaultRadius | Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem |
| renderNode | (payload: TreeSelectRenderNodePayload) => ReactNode | - | Custom node rendering in the dropdown |
| renderPill | (payload: TreeSelectRenderPillPayload) => ReactNode | - | Custom pill rendering in `multiple` and `checkbox` modes. Not called for the overflow pill displayed when `maxDisplayedValues` is exceeded. |
| required | boolean | false | Adds required attribute to the input and a red asterisk on the right side of label |
| rightSection | React.ReactNode | - | Content section displayed on the right side of the input |
| rightSectionPointerEvents | React.CSSProperties["pointerEvents"] | 'none' | Sets `pointer-events` styles on the `rightSection` element. Use `'all'` when section contains interactive elements (buttons, links). |
| rightSectionProps | React.ComponentProps<"div"> | - | Props passed down to the `rightSection` element |
| rightSectionWidth | React.CSSProperties["width"] | - | Right section width, used to set `width` of the section and input `padding-right`, by default equals to the input height |
| scrollAreaProps | ScrollAreaProps | - | Props for the ScrollArea in the dropdown |
| scrollBehavior | ScrollBehavior | 'instant' | `behavior` passed down to `element.scrollIntoView` when options are scrolled into view with keyboard navigation |
| searchValue | string | - | Controlled search value |
| searchable | boolean | false | Enables search filtering |
| size | MantineSize | 'sm' | Controls input `height`, horizontal `padding`, and `font-size` |
| success | React.ReactNode | - | Contents of `Input.Success` component. If not set, success is not displayed. |
| successProps | InputSuccessProps & DataAttributes & PlaceholderPolymorphicProps | - | Props passed down to the `Input.Success` component |
| value | string \| string[] \| null | - | Controlled value |
| virtualizer | ComponentType<ComboboxVirtualizerProps> | - | Component that renders visible nodes and manages scrolling in place of the dropdown ScrollArea |
| withAsterisk | boolean | false | If set, the required asterisk is displayed next to the label. Overrides `required` prop. Does not add required attribute to the input. |
| withErrorStyles | boolean | true | Determines whether the input should have red border and red text color when the `error` prop is set |
| withLines | boolean | true | Show tree connection lines between parent and child nodes |
| withSuccessStyles | boolean | true | Determines whether the input should have green border when the `success` prop is set |
| wrapPills | boolean | true | Determines whether pills wrap to the next line when they do not fit. When `false`, the input keeps one line: pills shrink with an ellipsis, combine with `maxDisplayedValues` to collapse the rest into the `+N more` pill |
| wrapperProps | WrapperProps | - | Props passed down to the root element |


#### Styles API

TreeSelect component supports Styles API. With Styles API, you can customize styles of any inner element. Follow the documentation to learn how to use CSS modules, CSS variables and inline styles to get full control over component styles.

**TreeSelect selectors**

| Selector | Static selector | Description |
|----------|----------------|-------------|
| wrapper | .mantine-TreeSelect-wrapper | Root element of the Input |
| input | .mantine-TreeSelect-input | Input element |
| section | .mantine-TreeSelect-section | Left and right sections |
| bottomSection | .mantine-TreeSelect-bottomSection | Bottom section element, rendered inside the input border at the bottom |
| root | .mantine-TreeSelect-root | Root element |
| childrenWrapper | .mantine-TreeSelect-childrenWrapper | Container of `children`, rendered only when `withBlockChildren` prop is set |
| label | .mantine-TreeSelect-label | Label element |
| required | .mantine-TreeSelect-required | Required asterisk element, rendered inside label |
| description | .mantine-TreeSelect-description | Description element |
| error | .mantine-TreeSelect-error | Error element |
| success | .mantine-TreeSelect-success | Success element |
| pill | .mantine-TreeSelect-pill | Value pill |
| inputField | .mantine-TreeSelect-inputField | Input field |
| pillsList | .mantine-TreeSelect-pillsList | List of pills, also contains input field |

**TreeSelect data attributes**

| Selector | Attribute | Condition | Value |
|----------|-----------|-----------|-------|
| option | data-combobox-selected | Option is selected | - |
| option | data-combobox-active | Options was activated by keyboard | - |
| option | data-combobox-disabled | Option is disabled | - |
