AI Web FeedsAI Web FeedsOpen web AI reader
  • Features
    Documentation

    Mermaid Diagrams

    Render beautiful diagrams in your documentation using Mermaid syntax

    Source: apps/web/content/docs/features/mermaid.mdx

    Overview

    Mermaid is a JavaScript-based diagramming and charting tool that uses Markdown-inspired syntax to create and modify diagrams dynamically. This site integrates Mermaid to enable rich, interactive diagrams in documentation.

    Features

    • Theme-aware: Diagrams automatically adapt to light/dark mode
    • Interactive: Clickable elements and tooltips
    • Multiple diagram types: Flowcharts, sequence diagrams, class diagrams, ER diagrams, and more
    • Simple syntax: Write diagrams using a Markdown-like syntax

    Basic Usage

    Method 1: Mermaid Code Blocks

    The simplest way to add a Mermaid diagram is using a fenced code block with the mermaid language identifier:

    ```mermaid
    graph TD;
        A[Start] --> B{Decision};
        B -->|Yes| C[Action 1];
        B -->|No| D[Action 2];
        C --> E[End];
        D --> E;
    ```

    Method 2: Component Syntax

    You can also use the <Mermaid> component directly for more control:

    <Mermaid
      chart="
    graph LR;
        A[Client] --> B[Load Balancer];
        B --> C[Server1];
        B --> D[Server2];"
    />

    Diagram Types

    Flowcharts

    Create process flows and decision trees:

    Sequence Diagrams

    Visualize interaction between components:

    Class Diagrams

    Document object-oriented structures:

    Entity Relationship Diagrams

    Model database schemas:

    State Diagrams

    Show state transitions:

    Gantt Charts

    Project timelines and scheduling:

    User Journey

    Map user experiences:

    Git Graph

    Visualize Git workflows:

    Advanced Features

    Subgraphs

    Organize complex diagrams with subgraphs:

    mermaid graph TB subgraph Frontend A[React App] B[Vue App] end subgraph Backend C[API Server] D[Auth Service] end subgraph Database E[(PostgreSQL)] F[(Redis)] end A --> C B --> C C --> D C --> E D --> F
    md ```mermaid graph TB subgraph Frontend A[React App] B[Vue App] end subgraph Backend C[API Server] D[Auth Service] end subgraph Database E[(PostgreSQL)] F[(Redis)] end A --> C B --> C C --> D C --> E D --> F ```

    Styling

    Customize diagram appearance with inline styles:

    Best Practices

    Keep It Simple

    • Start with simple diagrams and add complexity gradually
    • Use subgraphs to organize large diagrams
    • Keep labels concise and clear

    Use Consistent Naming

    • Use descriptive node IDs
    • Follow a naming convention across diagrams
    • Use consistent shapes for similar elements

    Example: Good vs. Not Ideal

    Troubleshooting

    Diagram Not Rendering

    • Ensure mermaid and next-themes are installed
    • Check console for syntax errors
    • Verify the diagram type is supported

    Theme Issues

    • The component automatically detects light/dark mode
    • If themes don't switch, check that RootProvider is properly configured

    Syntax Errors

    Resources

    Next Steps

    Mermaid Diagrams | AI Web Feeds