Signature
Parameters
Array of layout loader definitions.
Return value
void - This method does not return a value.
Layout algorithm interface
The loader must return an object implementing theLayoutAlgorithm interface:
Examples
Basic layout registration
Registering multiple layouts
Using external layout library
Complete layout implementation example
Using layout in diagram configuration
Fallback layout configuration
D3-based layout
Built-in layouts
Mermaid includes these layouts by default:- dagre: Hierarchical layout using the Dagre library (default)
- cose-bilkent: Force-directed layout using COSE (Compound Spring Embedder)
Usage notes
- Layouts are loaded lazily when first used
- Custom layouts must implement the
LayoutAlgorithminterface - The
layoutDataparameter contains nodes and edges with their properties - The
svgparameter is a D3 selection of the SVG element - The
helpersparameter provides access to internal Mermaid utilities - Layout algorithm names are case-sensitive
- If a requested layout is not found, Mermaid falls back to
dagre
Layout data structure
Related methods
- registerExternalDiagrams() - Register custom diagram types
- registerIconPacks() - Register icon packs
- initialize() - Configure Mermaid including layout settings