Skip to content

Function: toMermaid()

ts
function toMermaid(roots, options?): string;

Defined in: packages/core/src/mermaid.ts:30

Convert a structure tree to a Mermaid flowchart definition. Each node gets a stable id (n0, n1, …) in depth-first order; edges connect a parent to each child.

Parameters

roots

StructureNode[]

Top-level StructureNodes (an authored @structure).

options?

direction sets the flowchart orientation (default TD, top-down).

direction?

"TD" | "LR"

Returns

string

Mermaid source, or an empty string when there are no nodes.

Example

ts
toMermaid([{ selector: ".tabs", children: [{ selector: ".panel", children: [] }] }]);
// flowchart TD
//   n0[".tabs"]
//   n1[".panel"]
//   n0 --> n1

Released under the MIT License