GX Framework

Nodes and render tree

A GX node is the value that carries render structure from one component to the next. Use nodes when you want to assemble a tree, pass nested content around, or inspect the structure before it becomes HTML.

When programmers use nodes

Nodes are the common language between component functions, child slots, fragments, and render helpers. They let you keep composition explicit without flattening the tree into strings too early.

func Notice(title string, body gx.Node) gx.Node {
  return gx.Element("section", gx.Props{"class": "notice"},
    gx.Element("h2", nil, gx.Text(title)),
    body,
  )
}

Why the tree matters

The render tree preserves structure for rendering, snapshot tests, and runtime mounts. It is the layer you look at when you want to understand what a component produces before the output turns into HTML.

See also Rendering and Testing.