Mermaid Diagram Examples and Syntax Quick Reference
Mermaid works well in doc sites for flowcharts, sequence diagrams, and class diagrams. It writes directly in Markdown / MDX, has low maintenance cost, and is easier to update than screenshots.
Flowchart
Example
graph TD
A[Start] --> B{Condition}
B -->|Yes| C[End]
B -->|No| D[Process]
D --> B

Mind Map
Example
graph TD
A[Mind Map]
A --> B[Branch 1]
A --> C[Branch 2]
A --> D[Branch 3]
B --> E[Sub-branch 1]
B --> F[Sub-branch 2]
C --> G[Sub-branch 3]
C --> H[Sub-branch 4]
D --> I[Sub-branch 5]
D --> J[Sub-branch 6]

Sequence Diagram
Example
sequenceDiagram
participant User
participant System
User->>System: Login Request
System-->>User: Return Login Result

Gantt Chart
Example
gantt
title Project Plan
dateFormat YYYY-MM-DD
section Phase
Requirements Analysis :a1, 2024-06-01, 10d
System Design :after a1, 15d
Development : 2024-06-20, 30d
Testing : 2024-07-20, 20d

Class Diagram
Example
classDiagram
class Person{
+String name
+int age
+void speak()
}
class Employee{
+int employeeId
+double salary
}
Person <|-- Employee
