Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Diagram Types

mdbook-mermaid-mmdr supports all diagram types provided by mermaid-rs-renderer. Below are examples of the most commonly used types. Each section shows the Markdown source followed by the live rendered result.

Flowchart

```mermaid
flowchart LR
    A[Start] --> B{Decision}
    B -->|Yes| C[OK]
    B -->|No| D[Not OK]
```
YesNoStartDecisionOKNot OK

Sequence Diagram

```mermaid
sequenceDiagram
    participant A as Alice
    participant B as Bob
    A->>B: Hello Bob
    B-->>A: Hi Alice
    A->>B: How are you?
    B-->>A: Great!
```
Hello BobHi AliceHow are you?Great!AliceBobAliceBob

Class Diagram

```mermaid
classDiagram
    class Animal {
        +String name
        +int age
        +makeSound()
    }
    class Dog {
        +fetch()
    }
    Animal <|-- Dog
```
Animal+String name+int age+makeSound()Dog+fetch()

State Diagram

```mermaid
stateDiagram-v2
    [*] --> Idle
    Idle --> Processing : start
    Processing --> Done : complete
    Processing --> Error : fail
    Error --> Idle : reset
    Done --> [*]
```
startcompletefailresetDoneErrorIdleProcessing

Entity Relationship Diagram

```mermaid
erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
    PRODUCT ||--o{ LINE-ITEM : "is in"
```
placescontains"is in"CUSTOMERLINE-ITEMORDERPRODUCT

Gantt Chart

```mermaid
gantt
    title Project Timeline
    dateFormat YYYY-MM-DD
    section Phase 1
    Research       :a1, 2024-01-01, 30d
    Design         :a2, after a1, 20d
    section Phase 2
    Implementation :b1, after a2, 40d
    Testing        :b2, after b1, 15d
```
Project Timeline2024-01-012024-01-272024-02-232024-03-202024-04-15Phase 1Phase 2ResearchDesignImplementationTesting

Pie Chart

```mermaid
pie title Language Distribution
    "Rust" : 60
    "Python" : 25
    "Other" : 15
```
60%25%15%RustPythonOtherLanguage Distribution

Mindmap

```mermaid
mindmap
    root((Project))
        Frontend
            React
            CSS
        Backend
            Rust
            Database
        DevOps
            CI/CD
            Monitoring
```
BackendCI/CDCSSDatabaseDevOpsFrontendMonitoringReactRustProject

Inline Theme Directives

You can override the theme on a per-diagram basis using Mermaid’s %%{init: ...}%% directive:

```mermaid
%%{init: {"theme": "forest"}}%%
graph LR
    A --> B --> C
```
ABC

For the full list of supported diagram types, see the mermaid-rs-renderer documentation.