Skip to content

vooft/compose-treeview

Repository files navigation

Build and test Releases Maven Central License

badge-platform-jvm badge-platform-wasm badge-platform-android badge-platform-ios

badge-demo https://vooft.github.io/compose-treeview/

compose-treeview

A tree view for Compose Multiplatform. This project is a fork of bonsai by Adriel Cafe.

Supported platforms

  • Android
  • iOS
  • Desktop
  • Web (wasm) (demo)

Quick start

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)
}

About

Compose Multiplatform tree view implementation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages