# @salmonui/navigation/tree-view API reference

> 25 exported symbols of @salmonui/navigation/tree-view: 1 component, 1 function, 19 interfaces, 3 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/navigation/tree-view

```ts
import { … } from '@salmonui/navigation/tree-view';
```

## Components

### TreeView

Kind: component

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeView

```ts
function TreeView<T>(props: TreeViewProps<T>): ReactNode;
```

A hierarchical list (WAI-ARIA APG Tree View) over `data`, virtualized by
default. `ref` receives the TreeViewApi.

Props: [`TreeViewProps`](https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewProps) (its members are the props)

## Functions

### moveTreeItems

Kind: function

Page: https://salmonui.dev/docs/reference/navigation/tree-view/moveTreeItems

```ts
function moveTreeItems<T>(data: readonly T[], move: {
    readonly ids: readonly TreeViewKey[];
    readonly targetId: TreeViewKey;
    readonly position: TreeViewDropPosition;
    readonly items?: readonly T[];
}, options: MoveTreeItemsOptions<T>): T[];
```

Moves the items `ids` (taken from `data`, or from `items` when they come
from another tree) `before`, `after` or `into` the item `targetId`.

## Interfaces

### MoveTreeItemsOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/MoveTreeItemsOptions

```ts
interface MoveTreeItemsOptions<T> {
    readonly getItemId: (item: T) => TreeViewKey;
    readonly getChildren: (item: T) => readonly T[] | null | undefined;
    readonly withChildren: (item: T, children: readonly T[]) => T;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `getItemId` | `readonly getItemId: (item: T) => TreeViewKey;` |  |  |
| `getChildren` | `readonly getChildren: (item: T) => readonly T[] \| null \| undefined;` |  |  |
| `withChildren` | `readonly withChildren: (item: T, children: readonly T[]) => T;` |  | Returns a copy of `item` with `children`. |

### TreeViewApi

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewApi

```ts
interface TreeViewApi<T = unknown> {
    scrollToItem(id: TreeViewKey): void;
    focusItem(id: TreeViewKey): void;
    getItem(id: TreeViewKey): TreeViewItemInfo<T> | undefined;
    expandAll(options?: {
        readonly ids?: readonly TreeViewKey[];
        readonly level?: number;
    }): void;
    collapseAll(options?: {
        readonly ids?: readonly TreeViewKey[];
        readonly level?: number;
    }): void;
    checkAll(ids?: readonly TreeViewKey[]): void;
    uncheckAll(ids?: readonly TreeViewKey[]): void;
    getCheckedIds(): TreeViewKey[];
    getSelectedIds(): TreeViewKey[];
    getExpandedIds(): TreeViewKey[];
    startRename(id: TreeViewKey): void;
}
```

Commands props cannot express (`ref`).

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `scrollToItem` | `scrollToItem(id: TreeViewKey): void;` |  | Expands the ancestors and scrolls the item into view. |
| `focusItem` | `focusItem(id: TreeViewKey): void;` |  | Scrolls to the item and moves keyboard focus to it. |
| `getItem` | `getItem(id: TreeViewKey): TreeViewItemInfo<T> \| undefined;` |  |  |
| `expandAll` | `expandAll(options?: {     readonly ids?: readonly TreeViewKey[];     readonly level?: number; }): void;` |  | Expands every item (or `ids`), down to `level` (1-based) when given; one flatten. |
| `collapseAll` | `collapseAll(options?: {     readonly ids?: readonly TreeViewKey[];     readonly level?: number; }): void;` |  | Collapses every item (or `ids`), or the items at `level` and deeper. |
| `checkAll` | `checkAll(ids?: readonly TreeViewKey[]): void;` |  |  |
| `uncheckAll` | `uncheckAll(ids?: readonly TreeViewKey[]): void;` |  |  |
| `getCheckedIds` | `getCheckedIds(): TreeViewKey[];` |  |  |
| `getSelectedIds` | `getSelectedIds(): TreeViewKey[];` |  |  |
| `getExpandedIds` | `getExpandedIds(): TreeViewKey[];` |  |  |
| `startRename` | `startRename(id: TreeViewKey): void;` |  | Opens the inline editor (`renamable`). |

### TreeViewBeforeCheckedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewBeforeCheckedChangeEvent

```ts
interface TreeViewBeforeCheckedChangeEvent<T> extends TreeViewCancelableEvent {
    readonly id: TreeViewKey;
    readonly item: T;
    readonly checked: boolean;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `item` | `readonly item: T;` |  |  |
| `checked` | `readonly checked: boolean;` |  | The proposed state of the item (the cascade follows). |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `source` | `source: TreeViewEventSource;` | inherited |  |

### TreeViewBeforeExpandedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewBeforeExpandedChangeEvent

```ts
interface TreeViewBeforeExpandedChangeEvent<T> extends TreeViewCancelableEvent {
    readonly id: TreeViewKey;
    readonly item: T;
    readonly expanded: boolean;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `item` | `readonly item: T;` |  |  |
| `expanded` | `readonly expanded: boolean;` |  | The proposed state. |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `source` | `source: TreeViewEventSource;` | inherited |  |

### TreeViewBeforeMoveEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewBeforeMoveEvent

```ts
interface TreeViewBeforeMoveEvent<T> extends TreeViewCancelableEvent {
    readonly ids: readonly TreeViewKey[];
    readonly items: readonly T[];
    readonly targetId: TreeViewKey;
    readonly position: TreeViewDropPosition;
    readonly sourceTreeId: string | undefined;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ids` | `readonly ids: readonly TreeViewKey[];` |  |  |
| `items` | `readonly items: readonly T[];` |  |  |
| `targetId` | `readonly targetId: TreeViewKey;` |  |  |
| `position` | `readonly position: TreeViewDropPosition;` |  |  |
| `sourceTreeId` | `readonly sourceTreeId: string \| undefined;` |  | The `id` of the tree the items come from when it is another tree of the same `dragGroup`. |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `source` | `source: TreeViewEventSource;` | inherited |  |

### TreeViewBeforeRenameEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewBeforeRenameEvent

```ts
interface TreeViewBeforeRenameEvent<T> extends TreeViewCancelableEvent {
    readonly id: TreeViewKey;
    readonly item: T;
    readonly label: string;
    readonly previousLabel: string;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `item` | `readonly item: T;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `previousLabel` | `readonly previousLabel: string;` |  |  |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `source` | `source: TreeViewEventSource;` | inherited |  |

### TreeViewBeforeSelectedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewBeforeSelectedChangeEvent

```ts
interface TreeViewBeforeSelectedChangeEvent<T> extends TreeViewCancelableEvent {
    readonly selected: readonly TreeViewKey[];
    readonly id: TreeViewKey | null;
    readonly item: T | undefined;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selected` | `readonly selected: readonly TreeViewKey[];` |  | The proposed selection. |
| `id` | `readonly id: TreeViewKey \| null;` |  | The item the action started on (null for select all). |
| `item` | `readonly item: T \| undefined;` |  |  |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `source` | `source: TreeViewEventSource;` | inherited |  |

### TreeViewCancelableEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewCancelableEvent

```ts
interface TreeViewCancelableEvent {
    preventDefault(): void;
    readonly defaultPrevented: boolean;
    readonly source: TreeViewEventSource;
}
```

A cancellable `onBefore*` event: `preventDefault()` cancels the action.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewCheckedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewCheckedChangeEvent

```ts
interface TreeViewCheckedChangeEvent<T> {
    readonly checked: readonly TreeViewKey[];
    readonly id: TreeViewKey | null;
    readonly item: T | undefined;
    readonly source: TreeViewEventSource;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `checked` | `readonly checked: readonly TreeViewKey[];` |  | Every checked id after the change (fully checked parents included, mixed ones not); computed on first read. |
| `id` | `readonly id: TreeViewKey \| null;` |  | The toggled item; null for `checkAll` / `uncheckAll`. |
| `item` | `readonly item: T \| undefined;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewExpandedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewExpandedChangeEvent

```ts
interface TreeViewExpandedChangeEvent<T> {
    readonly expanded: readonly TreeViewKey[];
    readonly id: TreeViewKey | null;
    readonly item: T | undefined;
    readonly source: TreeViewEventSource;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `expanded` | `readonly expanded: readonly TreeViewKey[];` |  | Every expanded id after the change. |
| `id` | `readonly id: TreeViewKey \| null;` |  | The toggled item; null for `expandAll` / `collapseAll` and `*`. |
| `item` | `readonly item: T \| undefined;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewItemClickEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewItemClickEvent

```ts
interface TreeViewItemClickEvent<T> {
    readonly id: TreeViewKey;
    readonly item: T;
    readonly source: TreeViewEventSource;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `item` | `readonly item: T;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewItemContext

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewItemContext

```ts
interface TreeViewItemContext<T> {
    readonly item: T;
    readonly id: TreeViewKey;
    readonly level: number;
    readonly label: string;
    readonly expanded: boolean;
    readonly selected: boolean;
    readonly checked: boolean | 'mixed';
    readonly disabled: boolean;
    readonly loading: boolean;
    readonly error: unknown;
    retry(): void;
}
```

`renderItem` context: the rendered item and its state.

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `item` | `readonly item: T;` |  |  |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `level` | `readonly level: number;` |  | 1-based depth (`aria-level`). |
| `label` | `readonly label: string;` |  |  |
| `expanded` | `readonly expanded: boolean;` |  |  |
| `selected` | `readonly selected: boolean;` |  |  |
| `checked` | `readonly checked: boolean \| 'mixed';` |  |  |
| `disabled` | `readonly disabled: boolean;` |  |  |
| `loading` | `readonly loading: boolean;` |  |  |
| `error` | `readonly error: unknown;` |  | The rejection of `loadChildren` for this item, or undefined. |
| `retry` | `retry(): void;` |  | Loads the children again after an error. |

### TreeViewItemInfo

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewItemInfo

```ts
interface TreeViewItemInfo<T> {
    readonly item: T;
    readonly id: TreeViewKey;
    readonly level: number;
    readonly parentId: TreeViewKey | null;
    readonly expanded: boolean;
    readonly selected: boolean;
    readonly checked: boolean | 'mixed';
    readonly disabled: boolean;
    readonly visible: boolean;
}
```

`api.getItem(id)`.

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `item` | `readonly item: T;` |  |  |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `level` | `readonly level: number;` |  |  |
| `parentId` | `readonly parentId: TreeViewKey \| null;` |  |  |
| `expanded` | `readonly expanded: boolean;` |  |  |
| `selected` | `readonly selected: boolean;` |  |  |
| `checked` | `readonly checked: boolean \| 'mixed';` |  |  |
| `disabled` | `readonly disabled: boolean;` |  |  |
| `visible` | `readonly visible: boolean;` |  |  |

### TreeViewLinkProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewLinkProps

```ts
interface TreeViewLinkProps {
    readonly href: string;
    readonly className: string;
    readonly tabIndex: -1;
    readonly children: ReactNode;
}
```

Props a link item passes to `renderLink` (spread them on the link element).

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `href` | `readonly href: string;` |  |  |
| `className` | `readonly className: string;` |  |  |
| `tabIndex` | `readonly tabIndex: -1;` |  |  |
| `children` | `readonly children: ReactNode;` |  |  |

### TreeViewLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewLocaleText

```ts
interface TreeViewLocaleText {
    readonly loading: string;
    readonly loadError: string;
    readonly retry: string;
    readonly rename: string;
    readonly moved: string;
}
```

Static texts of `TreeView`; `{param}` templates. Plain JSON, safe to pass from a server component.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `loading` | `readonly loading: string;` |  |  |
| `loadError` | `readonly loadError: string;` |  |  |
| `retry` | `readonly retry: string;` |  |  |
| `rename` | `readonly rename: string;` |  | `{label}`: the inline editor's accessible name. |
| `moved` | `readonly moved: string;` |  | `{label}`, `{target}`: announced after a move. |

### TreeViewMoveEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewMoveEvent

```ts
interface TreeViewMoveEvent<T> {
    readonly ids: readonly TreeViewKey[];
    readonly items: readonly T[];
    readonly targetId: TreeViewKey;
    readonly position: TreeViewDropPosition;
    readonly sourceTreeId: string | undefined;
    readonly source: TreeViewEventSource;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ids` | `readonly ids: readonly TreeViewKey[];` |  |  |
| `items` | `readonly items: readonly T[];` |  | The moved items (from the source tree). |
| `targetId` | `readonly targetId: TreeViewKey;` |  |  |
| `position` | `readonly position: TreeViewDropPosition;` |  |  |
| `sourceTreeId` | `readonly sourceTreeId: string \| undefined;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewProps

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewProps

```ts
interface TreeViewProps<T> extends NativeProps {
    readonly data: readonly T[];
    readonly getItemId: (item: T) => TreeViewKey;
    readonly getItemLabel?: ((item: T) => string) | undefined;
    readonly getChildren?: ((item: T) => readonly T[] | null | undefined) | undefined;
    readonly getParentId?: ((item: T) => TreeViewKey | null | undefined) | undefined;
    readonly hasChildren?: ((item: T) => boolean) | undefined;
    readonly loadChildren?: ((item: T, options: {
        readonly signal: AbortSignal;
    }) => Promise<readonly T[]>) | undefined;
    readonly onLoadError?: ((error: unknown, item: T, id: TreeViewKey) => void) | undefined;
    readonly isItemDisabled?: ((item: T) => boolean) | undefined;
    readonly getItemIcon?: ((item: T) => ReactNode) | undefined;
    readonly getItemHref?: ((item: T) => string | undefined) | undefined;
    readonly renderLink?: ((props: TreeViewLinkProps, item: T) => ReactNode) | undefined;
    readonly getItemProps?: ((item: T, context: TreeViewItemContext<T>) => (HTMLAttributes<HTMLElement> & Record<`data-${string}`, string | undefined>) | undefined) | undefined;
    readonly renderItem?: ((context: TreeViewItemContext<T>) => ReactNode) | undefined;
    readonly selection?: 'none' | 'single' | 'multiple' | undefined;
    readonly selected?: readonly TreeViewKey[] | undefined;
    readonly onBeforeSelectedChange?: ((event: TreeViewBeforeSelectedChangeEvent<T>) => void) | undefined;
    readonly onSelectedChange?: ((event: TreeViewSelectedChangeEvent<T>) => void) | undefined;
    readonly expanded?: readonly TreeViewKey[] | undefined;
    readonly onBeforeExpandedChange?: ((event: TreeViewBeforeExpandedChangeEvent<T>) => void) | undefined;
    readonly onExpandedChange?: ((event: TreeViewExpandedChangeEvent<T>) => void) | undefined;
    readonly expandOn?: 'auto' | 'click' | 'doubleClick' | 'none' | undefined;
    readonly checkable?: boolean | undefined;
    readonly checked?: readonly TreeViewKey[] | undefined;
    readonly defaultChecked?: readonly TreeViewKey[] | undefined;
    readonly onBeforeCheckedChange?: ((event: TreeViewBeforeCheckedChangeEvent<T>) => void) | undefined;
    readonly onCheckedChange?: ((event: TreeViewCheckedChangeEvent<T>) => void) | undefined;
    readonly checkPropagation?: 'cascade' | 'none' | undefined;
    readonly cascadeToDisabled?: boolean | undefined;
    readonly checkOnClick?: boolean | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly renamable?: boolean | undefined;
    readonly onBeforeRename?: ((event: TreeViewBeforeRenameEvent<T>) => void) | undefined;
    readonly onRename?: ((event: TreeViewRenameEvent<T>) => void) | undefined;
    readonly draggable?: boolean | undefined;
    readonly dragGroup?: string | undefined;
    readonly onBeforeMove?: ((event: TreeViewBeforeMoveEvent<T>) => void) | undefined;
    readonly onMove?: ((event: TreeViewMoveEvent<T>) => void) | undefined;
    readonly onItemClick?: ((event: TreeViewItemClickEvent<T>) => void) | undefined;
    readonly onKeyDown?: ((event: KeyboardEvent<HTMLDivElement>) => void) | undefined;
    readonly sort?: 'asc' | 'desc' | null | undefined;
    readonly locale?: string | undefined;
    readonly height?: number | string | undefined;
    readonly virtualize?: boolean | undefined;
    readonly textWrap?: boolean | undefined;
    readonly rowHighlight?: 'full' | 'label' | undefined;
    readonly disabled?: boolean | undefined;
    readonly localeText?: Partial<TreeViewLocaleText> | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly ref?: Ref<TreeViewApi<T>> | undefined;
}
```

Members (52):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `readonly data: readonly T[];` |  | Root items. Nested with `getChildren`, or flat with `getParentId`. Application owned: moves and renames are reported, never applied. |
| `getItemId` | `readonly getItemId: (item: T) => TreeViewKey;` |  | Stable, unique id of an item (duplicates log a development warning). |
| `getItemLabel` | `readonly getItemLabel?: ((item: T) => string) \| undefined;` | optional | Accessible name, typeahead and sort text. Default: `String(id)`. |
| `getChildren` | `readonly getChildren?: ((item: T) => readonly T[] \| null \| undefined) \| undefined;` | optional |  |
| `getParentId` | `readonly getParentId?: ((item: T) => TreeViewKey \| null \| undefined) \| undefined;` | optional | Flat data: the parent id (null or an unknown id makes a root). |
| `hasChildren` | `readonly hasChildren?: ((item: T) => boolean) \| undefined;` | optional | Shows the expand twisty before children are known; expanding then calls `loadChildren`. |
| `loadChildren` | `readonly loadChildren?: ((item: T, options: {     readonly signal: AbortSignal; }) => Promise<readonly T[]>) \| undefined;` | optional | Loads the children of an item on its first expand. Reject to show the error state. |
| `onLoadError` | `readonly onLoadError?: ((error: unknown, item: T, id: TreeViewKey) => void) \| undefined;` | optional |  |
| `isItemDisabled` | `readonly isItemDisabled?: ((item: T) => boolean) \| undefined;` | optional |  |
| `getItemIcon` | `readonly getItemIcon?: ((item: T) => ReactNode) \| undefined;` | optional |  |
| `getItemHref` | `readonly getItemHref?: ((item: T) => string \| undefined) \| undefined;` | optional | The label renders as a link; a click anywhere on the row follows it. |
| `renderLink` | `readonly renderLink?: ((props: TreeViewLinkProps, item: T) => ReactNode) \| undefined;` | optional | Renders link items with another element (a router link); spread the props. |
| `getItemProps` | `` readonly getItemProps?: ((item: T, context: TreeViewItemContext<T>) => (HTMLAttributes<HTMLElement> & Record<`data-${string}`, string \| undefined>) \| undefined) \| undefined; `` | optional | Extra props for a rendered row (`title`, `className`, `data-*`). Pure; called for rendered rows only. |
| `renderItem` | `readonly renderItem?: ((context: TreeViewItemContext<T>) => ReactNode) \| undefined;` | optional | Replaces the label content of a rendered row (inside the link with `getItemHref`); `undefined` keeps the label. Pure; called for rendered rows only. |
| `selection` | `readonly selection?: 'none' \| 'single' \| 'multiple' \| undefined;` | optional | Default `'single'`. |
| `selected` | `readonly selected?: readonly TreeViewKey[] \| undefined;` | optional | Selected ids (reactive: applied when the array identity changes). |
| `onBeforeSelectedChange` | `readonly onBeforeSelectedChange?: ((event: TreeViewBeforeSelectedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `onSelectedChange` | `readonly onSelectedChange?: ((event: TreeViewSelectedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `expanded` | `readonly expanded?: readonly TreeViewKey[] \| undefined;` | optional | Expanded ids (reactive). |
| `onBeforeExpandedChange` | `readonly onBeforeExpandedChange?: ((event: TreeViewBeforeExpandedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `onExpandedChange` | `readonly onExpandedChange?: ((event: TreeViewExpandedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `expandOn` | `readonly expandOn?: 'auto' \| 'click' \| 'doubleClick' \| 'none' \| undefined;` | optional | What toggles a parent besides its twisty. `'auto'` (default): double-click with a mouse, tap on touch. |
| `checkable` | `readonly checkable?: boolean \| undefined;` | optional | Shows tri-state checkboxes (`aria-checked`). |
| `checked` | `readonly checked?: readonly TreeViewKey[] \| undefined;` | optional | Checked ids (reactive). |
| `defaultChecked` | `readonly defaultChecked?: readonly TreeViewKey[] \| undefined;` | optional | Initial checked ids when `checked` is not given; also the form reset value. |
| `onBeforeCheckedChange` | `readonly onBeforeCheckedChange?: ((event: TreeViewBeforeCheckedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `onCheckedChange` | `readonly onCheckedChange?: ((event: TreeViewCheckedChangeEvent<T>) => void) \| undefined;` | optional |  |
| `checkPropagation` | `readonly checkPropagation?: 'cascade' \| 'none' \| undefined;` | optional | Default `'cascade'`: parents and children follow each other, parents show mixed. |
| `cascadeToDisabled` | `readonly cascadeToDisabled?: boolean \| undefined;` | optional | Default true: a cascade also changes disabled descendants. |
| `checkOnClick` | `readonly checkOnClick?: boolean \| undefined;` | optional | A click on the row toggles its check. |
| `name` | `readonly name?: string \| undefined;` | optional | Form field name: one hidden input per checked id. |
| `form` | `readonly form?: string \| undefined;` | optional | Associates the hidden inputs with a form by id. |
| `renamable` | `readonly renamable?: boolean \| undefined;` | optional | F2 or `api.startRename` opens an inline editor (lazy chunk). |
| `onBeforeRename` | `readonly onBeforeRename?: ((event: TreeViewBeforeRenameEvent<T>) => void) \| undefined;` | optional |  |
| `onRename` | `readonly onRename?: ((event: TreeViewRenameEvent<T>) => void) \| undefined;` | optional |  |
| `draggable` | `readonly draggable?: boolean \| undefined;` | optional | Pointer drag and drop (lazy chunk) and keyboard moves (Alt + arrows). |
| `dragGroup` | `readonly dragGroup?: string \| undefined;` | optional | Trees with the same group exchange items. |
| `onBeforeMove` | `readonly onBeforeMove?: ((event: TreeViewBeforeMoveEvent<T>) => void) \| undefined;` | optional |  |
| `onMove` | `readonly onMove?: ((event: TreeViewMoveEvent<T>) => void) \| undefined;` | optional |  |
| `onItemClick` | `readonly onItemClick?: ((event: TreeViewItemClickEvent<T>) => void) \| undefined;` | optional |  |
| `onKeyDown` | `readonly onKeyDown?: ((event: KeyboardEvent<HTMLDivElement>) => void) \| undefined;` | optional | Runs before the built-in keys; `event.preventDefault()` skips them. |
| `sort` | `readonly sort?: 'asc' \| 'desc' \| null \| undefined;` | optional | Siblings sorted by `getItemLabel` with the locale's collator. Default: data order. |
| `locale` | `readonly locale?: string \| undefined;` | optional | Collator and plural locale. Default: the document language. |
| `height` | `readonly height?: number \| string \| undefined;` | optional | Height of the scroll box (px or CSS length). The server renders the rows that fit a number. |
| `virtualize` | `readonly virtualize?: boolean \| undefined;` | optional | Default true: only the rows in view are rendered. |
| `textWrap` | `readonly textWrap?: boolean \| undefined;` | optional | Labels wrap; row heights are measured. |
| `rowHighlight` | `readonly rowHighlight?: 'full' \| 'label' \| undefined;` | optional | Default `'full'`: the whole row shows hover and selection. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: Partial<TreeViewLocaleText> \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<TreeViewApi<T>> \| undefined;` | optional |  |

### TreeViewRenameEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewRenameEvent

```ts
interface TreeViewRenameEvent<T> {
    readonly id: TreeViewKey;
    readonly item: T;
    readonly label: string;
    readonly previousLabel: string;
    readonly source: TreeViewEventSource;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: TreeViewKey;` |  |  |
| `item` | `readonly item: T;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `previousLabel` | `readonly previousLabel: string;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

### TreeViewSelectedChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewSelectedChangeEvent

```ts
interface TreeViewSelectedChangeEvent<T> {
    readonly selected: readonly TreeViewKey[];
    readonly id: TreeViewKey | null;
    readonly item: T | undefined;
    readonly source: TreeViewEventSource;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selected` | `readonly selected: readonly TreeViewKey[];` |  |  |
| `id` | `readonly id: TreeViewKey \| null;` |  |  |
| `item` | `readonly item: T \| undefined;` |  |  |
| `source` | `readonly source: TreeViewEventSource;` |  |  |

## Types

### TreeViewDropPosition

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewDropPosition

```ts
type TreeViewDropPosition = 'before' | 'after' | 'into';
```

Where a moved item lands relative to the target.

### TreeViewEventSource

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewEventSource

```ts
type TreeViewEventSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

What caused an action.

### TreeViewKey

Kind: type

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TreeViewKey

```ts
type TreeViewKey = string | number;
```

An item id (`getItemId`).

## Constants

### TREE_VIEW_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/navigation/tree-view/TREE_VIEW_DEFAULT_LOCALE_TEXT

```ts
const TREE_VIEW_DEFAULT_LOCALE_TEXT: TreeViewLocaleText;
```
