Tree layouts

Show parent-child relationships with mind maps, indented trees, and fishbone diagrams

Choose a layout

Express parent-child relationships as edges with the parent as source and the child as target. Use one connected tree with a single root and no cycles.

GoalLayout and common options
Mind map branchesmindmap, with levelGap between levels and nodeGap between neighbors on the same side
Directory listingindented, with indent for indentation and rowHeight for row spacing
Root, categories, and itemsfishbone, with categoryGap between categories along the spine

Configuration and example

Use Tree layout to compare the three arrangements. The example also changes the edge routing. Indented trees use elbow connectors, while the fishbone layout uses angled branches.

Register each tree layout before using it. Optional layouts

Loading example…
Switch mindmap, indented, and fishbone on the same three-level tree. Reset restores mindmap
const layouts = {
  mindmap: {
    layout: {
      type: 'mindmap',
      direction: 'H',
      levelGap: 100,
      nodeGap: 24,
      getWidth: () => nodeSize,
      getHeight: (node: GraphNode) => node.id.length === 1 ? 64 : nodeSize,
      getSide: (node: GraphNode) => leftBranches.has(node.id[0]) ? 'left' : 'right',
    },
    edge: { type: 'line', style: { endArrow: false } },
  },
  indented: {
    layout: { type: 'indented', direction: 'LR', indent: 72, rowHeight: 30 },
    edge: { type: 'polyline', style: { router: 'indented', endArrow: false } },
  },
  fishbone: {
    layout: {
      type: 'fishbone',
      direction: 'LR',
      categoryGap: 156,
      categoryDistance: 130,
      itemHStep: 54,
      getWidth: () => nodeSize,
    },
    edge: { type: 'polyline', style: { router: 'fishbone', endArrow: false } },
  },
} satisfies Record<string, { layout: LayoutConfig; edge: EdgeConfig }>;

See the tree layout reference for defaults and other options.