Trees
tree renders an indented file-tree: one row per tree_node, indented by depth with ├─ └─ │ connector guides drawn between a parent and its children — the classic file-explorer look. Each node carries a title (its positional label) plus an optional icon and color. Nodes nest arbitrarily, so it suits a directory layout, a config tree, or any hierarchy where the structure is the point.
A tree is a diagram shape, so it lives inside a diagram { … }, is placed by x / y (or anchors), and its height is derived from the node count.
A file tree
iconset lucide {}
diagram { width = 360 height = 220
tree {
tree_node "src/" {
icon = "folder"
color = "#88c0d0"
tree_node "render/" {
icon = "folder"
tree_node "svg.rs" { icon = "file" }
tree_node "html.rs" { icon = "file" }
}
tree_node "lib.rs" { icon = "file" }
tree_node "tree.rs" { icon = "file" }
}
tree_node "Cargo.toml" { icon = "file" }
}
}
Icons resolve from any declared iconset (see Icons); a node's color is any CSS colour and themes its label + icon. Give a node an id to make it an edge target — an edge then attaches to that node's row (west / east), exactly like a node_table row.
Connecting to a node
Fields
Tree
| Property | Type | Required | Description |
|---|---|---|---|
| x | f64 | no | Top-left x placement in the diagram (or use anchors). |
| y | f64 | no | Top-left y placement in the diagram (or use anchors). |
| width | f64 | no | Tree width (default 280). Height is derived from the node count. |
| anchor_left | f64 | no | Diagram anchor insets (left/right/top/bottom), like any shape. |
| row_height | f64 | no | Height of every node row (default 24). The renderer can't measure content, so rows are fixed. |
| indent | f64 | no | Horizontal indent added per depth level (default 18). |
| id | identifier | no | Optional explicit HTML id (edge target for the whole tree). |
| class | list<utf8> | no | Optional style classes (applied to every label). |
| connect_points | list<AnchorSide> | no | Whole-tree edge-attach sides (default all four). Per-node sides default to west + east. |
Child blocks
| Slot | Accepts | Multiple | Description |
|---|---|---|---|
| nodes | tree_node | yes | The tree's top-level nodes, top to bottom; each may nest further nodes. |
TreeNode
| Property | Type | Required | Description |
|---|---|---|---|
| title | utf8 | yes | The node's label (its positional slot), e.g. node "render/". |
| icon | utf8 | no | Optional icon name (a bundled-pack glyph, like :name: / the icon block). |
| icon_set | utf8 | no | Iconset to draw icon from (else the first set that has it). |
| color | utf8 | no | Optional colour for the label + icon (any CSS colour). Themes the row. |
| id | identifier | no | Node id — the edge target for connecting to this node. |
| class | list<utf8> | no | Optional style classes (applied to this node's label). |
Child blocks
| Slot | Accepts | Multiple | Description |
|---|---|---|---|
| children | tree_node | yes | Child nodes nested under this one. |