esc
navigate select
Browse documentation

Callbacks

Every function prop TreeKit calls, and exactly when.

PropTypeDefaultDescription
onExpandedChange(ids: string[]) => voidAny time the expanded set changes — expand, collapse, or a keyboard-driven toggle.
onNodeExpand(node) => voidOnce, specifically when node transitions collapsed → expanded.
onNodeCollapse(node) => voidOnce, specifically when node transitions expanded → collapsed.
onCheckedChange(ids: string[], meta: { node }) => voidAny time the checked set changes. meta.node is whichever node the user directly toggled (cascaded descendants/ancestors aren't individually reported).
onSelectionChange(ids: string[], meta: { node }) => voidAny time the active/highlighted selection changes (selectionMode !== "none").
onNodeClick(node, event) => voidEvery row click, regardless of selectionMode or showCheckboxes — checkbox clicks are excluded (they stopPropagation).
onNodeDoubleClick(node, event) => voidEvery row double-click.
onKeyDown(event) => voidFires after TreeKit's own arrow/space/enter/home/end handling has run, so you can layer additional shortcuts without fighting built-in navigation.
onLoadChildren(node) => Promise<TreeNode[]>Called once per node, the first time it's expanded while lazily-loadable — see Async Loading.
filterFn(node, searchValue) => booleanCalled for every node on every searchValue change — not technically an event callback, but worth knowing it re-runs on every keystroke unless you debounce searchValue yourself.

Every callback is optional. TreeKit works fully uncontrolled with none of them provided — pass only the ones relevant to what your app needs to know.