Skip to content

Mermaid Diagram Style Guide

📋Page Status
Page Type:ContentStyle Guide →Standard knowledge base article
Quality:37 (Draft)
Importance:2 (Peripheral)
Words:422
Structure:
📊 3📈 6🔗 0📚 00%Score: 8/15
LLM Summary:Internal style guide for creating Mermaid diagrams in the wiki, recommending vertical layouts over horizontal (max 3-4 parallel nodes), providing semantic color palette, and advocating tables over diagrams for taxonomies. Includes practical width limits and anti-patterns for common diagram issues.
<Mermaid client:load chart={`
flowchart TD
A[Node A] --> B[Node B]
`} />

Prefer Vertical (TD/TB) Over Horizontal (LR)

Section titled “Prefer Vertical (TD/TB) Over Horizontal (LR)”

The content area is often narrow (600-800px). Wide diagrams get compressed and become unreadable.

Bad: 5 parallel branches with 4 children each = 20+ nodes horizontally

Good: Linear flow with subgraphs, or convert to a table

If your diagram is essentially a taxonomy or matrix, use a markdown table:

CategoryType AType BType C
Row 1ValueValueValue
Row 2ValueValueValue

Tables handle narrow viewports gracefully; wide tree diagrams don’t.

Diagram TypeMax Horizontal NodesNotes
Flowchart3-4 parallel pathsUse subgraphs to stack
Pie chartN/AAlways works
QuadrantN/AAlways works
Timeline4-5 items per rowWrap to multiple sections
Sequence4-5 participantsGets cramped beyond this

Use these semantic colors for consistency across the wiki:

style NodeName fill:#ffcccc /* Light red - high risk/danger */
style NodeName fill:#ffddcc /* Light orange - medium risk */
style NodeName fill:#ffeedd /* Light peach - low risk */
style NodeName fill:#ffe1e1 /* Pink - warning */
style NodeName fill:#ff9999 /* Darker red - critical */
style NodeName fill:#ccffcc /* Light green - positive/intervention */
style NodeName fill:#cceeff /* Light blue - neutral/factor */
style NodeName fill:#fff4e1 /* Light yellow - category/dimension */
style NodeName fill:#e1f5ff /* Pale blue - root/overview */
Loading diagram...
Use CaseDiagram TypeReliabilityExample
Process flowflowchart TDHighDecision trees, pipelines
Causal relationshipsflowchart with labeled edgesHighInfluence diagrams
ProportionspieHighRisk breakdown, allocation
2x2 comparisonsquadrantChartHighPriority matrices
Temporal sequencestimelineMediumRoadmaps
State changesstateDiagram-v2MediumSystem states
Actor interactionssequenceDiagramLowAvoid - use tables instead
Loading diagram...
Loading diagram...
Loading diagram...

Trees with 5+ branches, each with children, become unreadable:

A --> B --> B1, B2, B3, B4
A --> C --> C1, C2, C3, C4
A --> D --> D1, D2, D3, D4
...

Fix: Use a table, or restructure as vertical flow with subgraphs.

Stacking 3+ subgraphs with 4-6 nodes each creates diagrams that are 800+ pixels tall:

subgraph "Level 1"
6 nodes chained vertically
end
subgraph "Level 2"
6 more nodes
end
subgraph "Level 3"
5 more nodes
end

Fix: Use a table for the details, with a small summary diagram showing just the phases/levels.

More than 15-20 nodes makes diagrams cluttered. Split into multiple diagrams or simplify.

Keep node text short (2-4 words). Put details in the surrounding text.

/* Bad */
A[This is a very long label that explains everything about the node]
/* Good */
A[Short Label]

Use subgraphs to create vertical sections in complex diagrams:

Loading diagram...

This keeps the diagram tall rather than wide.