Skip to content

Mermaid edge label syntax

Mermaid edge label syntax allows users to define the text that appears on the lines connecting nodes (edges) in diagrams, such as flowcharts.^[600-developer-tools-obsidian-johnny-ob-037.md]

Syntax formats

The basic syntax for adding a label to an edge involves placing the text between the arrow connectors.^[600-developer-tools-obsidian-johnny-ob-037.md]

Double hyphen format

In this format, the label is placed between two double hyphens (--).^[600-developer-tools-obsidian-johnny-ob-037.md]

graph LR
    A -- Label Text --> B

This is explicitly demonstrated in the horizontal flowchart example where a condition is labeled as a=1:^[600-developer-tools-obsidian-johnny-ob-037.md] C -- a=1 --> D

Pipe format

Alternatively, labels can be enclosed within pipes (|) when used with standard arrows.^[600-developer-tools-obsidian-johnny-ob-037.md]

graph TD
    C --> |Label Text| D

This style is used in the vertical flowchart example:^[600-developer-tools-obsidian-johnny-ob-037.md] C --> |a=1| D

Sources

  • 600-developer-tools-obsidian-johnny-ob-037.md