LazyTree
A lazily-rendered, expand/collapse tree for Compose Multiplatform. Only the currently-visible nodes are composed, so it scales to large trees. Expansion state is remembered internally, keyed by node identity.
LazyTree(root) { node, depth, expanded, toggle ->
Row(Modifier.padding(start = (depth * 16).dp).clickable(onClick = toggle)) {
if (!node.isLeaf) Text(if (expanded) "▾" else "▸")
Text(node.value.toString())
}
}Parameters
the root of the tree to display.
the Modifier applied to the underlying LazyColumn.
whether nodes start expanded.
renders a single node. Receives the node, its depth (root = 0), whether it is expanded, and a toggle callback that flips this node's expansion state.
Convenience overload of LazyTree that renders each node with the built-in TreeNodeRow, so the common case is a single call:
LazyTree(root)Use the overload that takes a nodeContent lambda when you need full control over a node's look.
Parameters
the root of the tree to display.
the Modifier applied to the underlying LazyColumn.
whether nodes start expanded.
the horizontal indentation applied per depth level.
maps a node's value to the text shown. Defaults to toString().