esc
↑↓ navigate↵ select
Browse documentation

Callbacks

Every function prop TreeKit calls, and exactly when.

PropTypeDefaultDescription
onExpandedChange(ids: string[]) => void—Any time the expanded set changes — expand, collapse, or a keyboard-driven toggle.
onNodeExpand(node) => void—Once, specifically when node transitions collapsed → expanded.
onNodeCollapse(node) => void—Once, specifically when node transitions expanded → collapsed.
onCheckedChange(ids: string[], meta: { node }) => void—Any 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 }) => void—Any time the active/highlighted selection changes (selectionMode !== "none").
onNodeClick(node, event) => void—Every row click, regardless of selectionMode or showCheckboxes — checkbox clicks are excluded (they stopPropagation).
onNodeDoubleClick(node, event) => void—Every row double-click.
onKeyDown(event) => void—Fires 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) => boolean—Called 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.