mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
5bb6fc2aff
* Update components/mermaid-diagrams.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> * Update es/components/mermaid-diagrams.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> * Apply suggestion from @ethanpalm * Update components/mermaid-diagrams.mdx * Apply suggestion from @ethanpalm --------- Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
127 lines
3.4 KiB
Plaintext
127 lines
3.4 KiB
Plaintext
---
|
|
title: "Mermaid"
|
|
description: "Create flowcharts, diagrams, and visualizations with Mermaid syntax."
|
|
keywords: ["Mermaid", "flowcharts", "diagrams"]
|
|
---
|
|
|
|
[Mermaid](https://mermaid.js.org/) lets you build flowcharts, sequence diagrams, Gantt charts, and other diagrams using text and code.
|
|
|
|
For a complete list of supported diagram types and syntax, see the [Mermaid documentation](https://mermaid.js.org/intro/).
|
|
|
|
```mermaid placement="top-right"
|
|
flowchart LR
|
|
subgraph subgraph1
|
|
direction TB
|
|
top1[top] --> bottom1[bottom]
|
|
end
|
|
subgraph subgraph2
|
|
direction TB
|
|
top2[top] --> bottom2[bottom]
|
|
end
|
|
%% ^ These subgraphs are identical, except for the links to them:
|
|
|
|
%% Link *to* subgraph1: subgraph1 direction is maintained
|
|
outside --> subgraph1
|
|
%% Link *within* subgraph2:
|
|
%% subgraph2 inherits the direction of the top-level graph (LR)
|
|
outside ---> top2
|
|
```
|
|
|
|
````mdx Mermaid flowchart example
|
|
```mermaid placement="top-right"
|
|
flowchart LR
|
|
subgraph subgraph1
|
|
direction TB
|
|
top1[top] --> bottom1[bottom]
|
|
end
|
|
subgraph subgraph2
|
|
direction TB
|
|
top2[top] --> bottom2[bottom]
|
|
end
|
|
%% ^ These subgraphs are identical, except for the links to them:
|
|
|
|
%% Link *to* subgraph1: subgraph1 direction is maintained
|
|
outside --> subgraph1
|
|
%% Link *within* subgraph2:
|
|
%% subgraph2 inherits the direction of the top-level graph (LR)
|
|
outside ---> top2
|
|
```
|
|
````
|
|
|
|
## ELK layout support
|
|
|
|
Mintlify supports the [ELK (Eclipse Layout Kernel)](https://www.eclipse.org/elk/) layout engine for Mermaid diagrams. ELK optimizes arrangement to reduce overlapping and improve readability, which is useful for large or complex diagrams.
|
|
|
|
To use ELK layout in your Mermaid diagrams, add the `%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%` directive at the beginning of your diagram:
|
|
|
|
````mdx ELK layout example
|
|
```mermaid
|
|
%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
|
|
flowchart LR
|
|
A[Start] --> B[Process 1]
|
|
B --> C[Process 2]
|
|
B --> D[Process 3]
|
|
C --> E[End]
|
|
D --> E
|
|
```
|
|
````
|
|
|
|
## Interactive controls
|
|
|
|
All Mermaid diagrams include interactive zoom and pan controls. By default, controls appear when the diagram height exceeds 120px.
|
|
|
|
- **Zoom in/out**: Use the zoom buttons to increase or decrease the diagram scale.
|
|
- **Pan**: Use the directional arrows to move around the diagram.
|
|
- **Reset view**: Click the reset button to return to the original view.
|
|
|
|
The controls are especially useful for large or complex diagrams that don't fit entirely in the viewport.
|
|
|
|
## Properties
|
|
|
|
<ResponseField name="actions" type="boolean">
|
|
Show or hide the interactive controls. When set, this overrides the default behavior (controls shown when diagram height exceeds 120px).
|
|
</ResponseField>
|
|
|
|
<ResponseField name="placement" type="string" default="bottom-right">
|
|
Position of the interactive controls. Options: `top-left`, `top-right`, `bottom-left`, `bottom-right`.
|
|
</ResponseField>
|
|
|
|
### Examples
|
|
|
|
Hide controls on a diagram:
|
|
|
|
````mdx
|
|
```mermaid actions={false}
|
|
flowchart LR
|
|
A --> B
|
|
```
|
|
````
|
|
|
|
Show controls in the top-left corner:
|
|
|
|
````mdx
|
|
```mermaid placement="top-left"
|
|
flowchart LR
|
|
A --> B
|
|
```
|
|
````
|
|
|
|
Combine both properties:
|
|
|
|
````mdx
|
|
```mermaid placement="top-left" actions={true}
|
|
flowchart LR
|
|
A --> B
|
|
```
|
|
````
|
|
|
|
## Syntax
|
|
|
|
To create a Mermaid diagram, write your diagram definition inside a Mermaid code block.
|
|
|
|
````mdx
|
|
```mermaid
|
|
// Your mermaid diagram code here
|
|
```
|
|
````
|