https://vooft.github.io/compose-treeview/
A tree view for Compose Multiplatform. This project is a fork of bonsai by Adriel Cafe.
- Android
- iOS
- Desktop
- Web (wasm) (demo)
Add the dependency to your project:
kotlin {
...
sourceSets {
commonMain.dependencies {
implementation("io.github.vooft:compose-treeview-core:<version>")
}
}
}
Create a tree using DSL:
@Composable
fun TreeViewExample() {
// build tree structure
val tree = Tree {
Branch("Mammalia") {
Branch("Carnivora") {
Branch("Canidae") {
Branch("Canis") {
Leaf("Wolf", customIcon = { EmojiIcon("🐺") })
Leaf("Dog", customIcon = { EmojiIcon("🐶") })
}
}
Branch("Felidae") {
Branch("Felis") {
Leaf("Cat", customIcon = { EmojiIcon("🐱") })
}
Branch("Panthera") {
Leaf("Lion", customIcon = { EmojiIcon("🦁") })
}
}
}
}
}
// render the tree
TreeView(tree)
}