# TreeViewProps (@salmonui/navigation/tree-view)

> The TreeViewProps interface of @salmonui/navigation/tree-view.

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

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

Entry index: https://salmonui.dev/docs/reference/navigation/tree-view (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/navigation/tree-view.md).

## Reference

Kind: interface

```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 |  |
