esc
navigate select
Browse documentation

<TreeKit />

Every prop the TreeKit component accepts, grouped by concern.

TreeKit is generic over your node data: TreeKit<T>, inferred automatically from the data prop in almost every case. See Types for the full type definitions referenced below.

Data

PropTypeDefaultDescription
data*TreeNode<T>[]Root nodes of the tree. Treated as immutable — TreeKit never mutates it.

Expansion

PropTypeDefaultDescription
expandedIdsstring[]Controlled set of expanded node ids.
defaultExpandedIdsstring[]Initial expanded ids for uncontrolled usage.
onExpandedChange(ids: string[]) => voidFires whenever the expanded set changes.
onNodeExpand(node: TreeNode<T>) => voidFires when a specific node transitions to expanded.
onNodeCollapse(node: TreeNode<T>) => voidFires when a specific node transitions to collapsed.
expandTrigger"chevron" | "label" | "either""either"What triggers expand/collapse for a node with children. "either" means the whole row, not just the chevron.

Checkbox selection

PropTypeDefaultDescription
showCheckboxesbooleantrueRender checkboxes at all.
checkOnClickbooleantrueWhether clicking anywhere on a leaf row's body also toggles its checkbox, not just the checkbox itself.
checkedIdsstring[]Controlled checked ids.
defaultCheckedIdsstring[]Initial checked ids for uncontrolled usage.
onCheckedChange(ids: string[], meta: { node: TreeNode<T> }) => voidFires whenever the checked set changes.
selectionPropagation{ toChildren?: boolean; toParents?: boolean }{ toChildren: true, toParents: true }Cascade rules — see Selection.

Active / row selection

PropTypeDefaultDescription
selectionMode"none" | "single" | "multiple""none"Whether row clicks drive an 'active' selection, independent of checkboxes.
selectedIdsstring[]Controlled selected (active) ids.
defaultSelectedIdsstring[]Initial selected ids for uncontrolled usage.
onSelectionChange(ids: string[], meta: { node: TreeNode<T> }) => voidFires whenever the active selection changes.

Disabled nodes

PropTypeDefaultDescription
disabledBehavior{ cascadeToChildren?: boolean; allowExpand?: boolean }{ cascadeToChildren: true, allowExpand: true }How disabled state propagates — see Disabled Nodes.

Interaction callbacks

PropTypeDefaultDescription
onNodeClick(node: TreeNode<T>, event: MouseEvent) => voidFires on any row click, regardless of selectionMode.
onNodeDoubleClick(node: TreeNode<T>, event: MouseEvent) => voidFires on row double-click.
onKeyDown(event: KeyboardEvent) => voidFires after TreeKit's own keyboard handling, for additional shortcuts.

Search

PropTypeDefaultDescription
searchValuestringActive search term. Empty string disables filtering.
filterFn(node: TreeNode<T>, value: string) => booleancase-insensitive label matchCustom match predicate.
highlightMatchesbooleantrueWrap matched substrings in <mark> in the default renderer.
autoExpandOnSearchbooleantrueAuto-reveal ancestors of a match.

Async loading

PropTypeDefaultDescription
onLoadChildren(node: TreeNode<T>) => Promise<TreeNode<T>[]>Called on first expand of a node with hasChildren and no children array.

Rendering & appearance

PropTypeDefaultDescription
renderNode(context: TreeNodeRenderContext<T>) => ReactNodeReplace row markup entirely — see Custom Rendering.
iconsTreeKitIcons<T>Chevron / leaf / loading icon overrides — see Icons.
classNamesTreeKitClassNamesExtra classes on TreeKit's internal row parts — see Styling.
variant"default" | "connected" | "compact" | "spacious" | "file-explorer""default"Built-in layout preset — see Themes & Variants.
rowHeightnumber32Row height in px. Drives virtualization math.
indentnumber18Indentation per level, in px.
disableAnimationsbooleanfalseForce all transitions/animations off.

Virtualization

PropTypeDefaultDescription
virtualizedbooleanfalseOnly mount rows in the current scroll viewport.
heightnumberRequired with virtualized — fixed pixel viewport height.
overscannumber6Extra rows rendered outside the viewport.

Misc / DOM

PropTypeDefaultDescription
classNamestringExtra class on the root element.
styleCSSPropertiesInline styles on the root — also how you set CSS variables per-instance.
idstringid attribute on the root element.
aria-label / aria-labelledbystringAccessible name for the root role="tree" element.