tree

tree renders an indented file-tree: one row per tree_node, indented by depth with the classic file-explorer connector guides drawn between a parent and its children. Each node carries a title (its positional label) plus an optional icon and color, and nodes nest arbitrarily, so it suits a directory layout, a config tree, or any hierarchy. A tree is a diagram shape, so it lives inside a diagram and is placed by x / y (or anchors).

An indented file-tree diagram shape — one row per tree_node, with file-explorer connector guides between parents and children.

Preview

src/render/svg.rshtml.rslib.rstree.rsCargo.toml
src/render/svg.rshtml.rslib.rstree.rsCargo.toml

Example

diagram {
  width = 360
  height = 220
  tree {
    tree_node "src/" {
      icon = "lucide.folder"
      tree_node "render/" {
        icon = "lucide.folder"
        tree_node "svg.rs" {
          icon = "lucide.file"
        }
        tree_node "html.rs" {
          icon = "lucide.file"
        }
      }
      tree_node "lib.rs" {
        icon = "lucide.file"
      }
      tree_node "tree.rs" {
        icon = "lucide.file"
      }
    }
    tree_node "Cargo.toml" {
      icon = "lucide.file"
    }
  }
}
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.

One row of a tree; carries a positional title label plus an optional icon and color, and nests further tree_nodes arbitrarily.

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.

Icons resolve from any declared iconset; a node's color is any CSS colour and themes its label and 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 connecting any other shape.