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

src/render/svg.rshtml.rslib.rstree.rsCargo.toml
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

configportsauth

open by default

Fields

Tree

PropertyTypeRequiredDescription
xf64noTop-left x placement in the diagram (or use anchors).
yf64noTop-left y placement in the diagram (or use anchors).
widthf64noTree width (default 280). Height is derived from the node count.
anchor_leftf64noDiagram anchor insets (left/right/top/bottom), like any shape.
row_heightf64noHeight of every node row (default 24). The renderer can't measure content, so rows are fixed.
indentf64noHorizontal indent added per depth level (default 18).
ididentifiernoOptional explicit HTML id (edge target for the whole tree).
classlist<utf8>noOptional style classes (applied to every label).
connect_pointslist<AnchorSide>noWhole-tree edge-attach sides (default all four). Per-node sides default to west + east.

Child blocks

SlotAcceptsMultipleDescription
nodestree_nodeyesThe tree's top-level nodes, top to bottom; each may nest further nodes.

TreeNode

PropertyTypeRequiredDescription
titleutf8yesThe node's label (its positional slot), e.g. node "render/".
iconutf8noOptional icon name (a bundled-pack glyph, like :name: / the icon block).
icon_setutf8noIconset to draw icon from (else the first set that has it).
colorutf8noOptional colour for the label + icon (any CSS colour). Themes the row.
ididentifiernoNode id — the edge target for connecting to this node.
classlist<utf8>noOptional style classes (applied to this node's label).

Child blocks

SlotAcceptsMultipleDescription
childrentree_nodeyesChild nodes nested under this one.