--- title: Mermaid createTime: 2025/10/08 19:34:16 icon: file-icons:mermaid permalink: /en/guide/chart/mermaid/ --- ## Overview The theme supports embedding diagrams generated by [Mermaid](https://mermaid.js.org/) within articles. This feature is powered by [@vuepress/plugin-markdown-chart](https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/). ## Configuration This feature is not enabled by default in the theme. You need to install the [mermaid](https://mermaid.js.org/) library in your project. ::: npm-to ```sh npm install mermaid ``` ::: Then, enable the feature in your `.vuepress/config.ts` configuration file: ```ts title=".vuepress/config.ts" export default defineUserConfig({ theme: plumeTheme({ markdown: { mermaid: true, // [!code ++] }, }) }) ``` ::: note The following documentation is forked from [@vuepress/plugin-markdown-chart](https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/mermaid.html) and is provided under the[MIT](https://github.com/vuepress/ecosystem/blob/main/LICENSE) license. ::: ## Syntax ````md ```mermaid ``` ```` In addition to using the `mermaid` code block, you can also directly use the following code block types: - class: `classDiagram` - c4c: `C4Context` - er: `erDiagram` - gantt: `gantt` - git-graph: `gitGraph` - journey: `journey` - mindmap: `mindmap` - pie: `pie` - quadrant: `quadrantChart` - requirement: `requirementDiagram` - sankey: `sankey-beta` - sequence: `sequenceDiagram` - state: `stateDiagram-v2` - timeline: `timeline` - xy: `xychart-beta` You do not need to declare the diagram type again, nor do you need to indent the diagram code. When the diagram supports setting a title, you can add the title directly after the code block info: ````md ```sequence Diagram Title ``` ```` Refer to the [Mermaid documentation](https://mermaid.js.org/) for configuration details. ## Advanced Usage You can import and use `defineMermaidConfig` in the [Client Configuration File](https://vuejs.press/guide/configuration.html#client-configuration-file) to customize Mermaid settings: ```ts import { defineMermaidConfig } from '@vuepress/plugin-markdown-chart/client' import { defineClientConfig } from 'vuepress/client' defineMermaidConfig({ // Set mermaid options here }) export default defineClientConfig({ // ... }) ``` ## Examples ### Flowchart **Input:** **Output:** ### Sequence Diagram **Input:** **Output:** ### Class Diagram **Input:** **Output:** ### State Diagram **Input:** **Output:** ### Entity Relationship Diagram **Input:** **Output:** ### User Journey Diagram **Input:** **Output:** ### Gantt Chart **Input:** :::: details View Code :::: **Output:** ### Pie Chart **Input:** ````md ```pie title What Voldemort doesn't have? "FRIENDS" : 2 "FAMILY" : 3 "NOSE" : 45 ``` ```` **Output:** ```pie title What Voldemort doesn't have? "FRIENDS" : 2 "FAMILY" : 3 "NOSE" : 45 ``` ### Git Graph **Input:** :::: details View Code :::: **Output:** ### C4 Diagram **Input:** :::: details View Code :::: **Output:** ### Mindmap **Input:** **Output:** ### Timeline Diagram **Input:** **Output:** ### Sankey Diagram **Input:** :::: details View Code :::: **Output:** ### Requirement Diagram **Input:** **Output:** ### Quadrant Chart **Input:** **Output:** ### XY Chart **Input:** **Output:** ### Block Diagram **Input:** **Output:** ### Complex Example **Input:** :::: details View Code :::: **Output:**