
Composable tree view with lazy rendering, connector lines drawn in one layout pass to avoid flicker, configurable indentation, icons, gaps, and optional always-expanded mode.
A Kotlin Multiplatform Compose library for rendering collapsible tree views, targeting Android and JVM (desktop).
LazyColumn — handles large trees efficientlyModifier.drawBehind, resolving in a single layout pass with no recomposition flickerAdd the dependency to your module's build.gradle.kts:
dependencies {
implementation("systems.untangle:kaju:0.1.0")
}data class FileNode(val id: Int, val name: String, val children: List<FileNode> = emptyList())
val root = FileNode(
id = 0, name = "root", children = listOf(
FileNode(id = 1, name = "src", children = listOf(
FileNode(id = 2, name = "Main.kt"),
FileNode(id = 3, name = "Utils.kt"),
)),
FileNode(id = 4, name = "build.gradle.kts"),
)
)
@Composable
fun MyTree() {
val state = rememberKajuState<Int>()
Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = state,
) { node ->
Text(node.name)
}
}Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = rememberKajuState(),
collapsible = false,
) { node ->
Text(node.name)
}val config = KajuConfig(
indentation = 16.dp,
itemsGap = 8.dp,
itemLeftPadding = 12.dp,
showLines = true,
lineColor = Color.Gray,
icons = KajuIcons(
collapsed = myCollapsedIcon,
expanded = myExpandedIcon,
)
)
Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = rememberKajuState(),
config = config,
) { node ->
Text(node.name)
}| Symbol | Description |
|---|---|
Kaju |
Main composable. Renders the tree inside a LazyColumn. |
KajuState<T> |
Holds the set of expanded node ids. |
rememberKajuState<T>() |
Creates and remembers a KajuState across recompositions. |
KajuConfig |
Visual configuration for the tree. |
DefaultKajuConfig |
Default configuration values. |
KajuIcons |
Pair of ImageVector for collapsed and expanded states. |
MIT
A Kotlin Multiplatform Compose library for rendering collapsible tree views, targeting Android and JVM (desktop).
LazyColumn — handles large trees efficientlyModifier.drawBehind, resolving in a single layout pass with no recomposition flickerAdd the dependency to your module's build.gradle.kts:
dependencies {
implementation("systems.untangle:kaju:0.1.0")
}data class FileNode(val id: Int, val name: String, val children: List<FileNode> = emptyList())
val root = FileNode(
id = 0, name = "root", children = listOf(
FileNode(id = 1, name = "src", children = listOf(
FileNode(id = 2, name = "Main.kt"),
FileNode(id = 3, name = "Utils.kt"),
)),
FileNode(id = 4, name = "build.gradle.kts"),
)
)
@Composable
fun MyTree() {
val state = rememberKajuState<Int>()
Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = state,
) { node ->
Text(node.name)
}
}Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = rememberKajuState(),
collapsible = false,
) { node ->
Text(node.name)
}val config = KajuConfig(
indentation = 16.dp,
itemsGap = 8.dp,
itemLeftPadding = 12.dp,
showLines = true,
lineColor = Color.Gray,
icons = KajuIcons(
collapsed = myCollapsedIcon,
expanded = myExpandedIcon,
)
)
Kaju(
header = root,
rootSelector = { it },
leavesRetriever = { it.children },
identifier = { it.id },
treeState = rememberKajuState(),
config = config,
) { node ->
Text(node.name)
}| Symbol | Description |
|---|---|
Kaju |
Main composable. Renders the tree inside a LazyColumn. |
KajuState<T> |
Holds the set of expanded node ids. |
rememberKajuState<T>() |
Creates and remembers a KajuState across recompositions. |
KajuConfig |
Visual configuration for the tree. |
DefaultKajuConfig |
Default configuration values. |
KajuIcons |
Pair of ImageVector for collapsed and expanded states. |
MIT