| title | Mermaid Plugin | ||||
|---|---|---|---|---|---|
| description | Render diagrams and flowcharts with mermaid.js syntax | ||||
| section | Plugins | ||||
| difficulty | beginner | ||||
| tags |
|
Render diagrams and flowcharts with mermaid.js syntax.
:::tabs
// JavaScript
import { mermaidPlugin } from '@goobits/docs-engine/plugins';
export default {
preprocess: [
mdsvex({
remarkPlugins: [
mermaidPlugin(),
// ... other plugins
],
}),
],
};// TypeScript
import { mdsvex } from 'mdsvex';
import { mermaidPlugin } from '@goobits/docs-engine/plugins';
const config = {
preprocess: [
mdsvex({
remarkPlugins: [
mermaidPlugin(),
// ... other plugins
],
}),
],
};
export default config;:::
<script>
import { MermaidHydrator } from '@goobits/docs-engine/components';
</script>
<MermaidHydrator />
<slot />```mermaid
graph LR
A[Start] --> B[Process]
B --> C[End]
``````mermaid
flowchart TD
Start([Start]) --> Decision{Is it?}
Decision -->|Yes| End1([Success])
Decision -->|No| End2([Failure])
```Result:
flowchart TD
Start([Start]) --> Decision{Is it?}
Decision -->|Yes| End1([Success])
Decision -->|No| End2([Failure])
```mermaid
sequenceDiagram
participant Client
participant Server
Client->>Server: Request
Server-->>Client: Response
```Result:
sequenceDiagram
participant Client
participant Server
Client->>Server: Request
Server-->>Client: Response
```mermaid
stateDiagram-v2
[*] --> Idle
Idle --> Running
Running --> Completed
Running --> Failed
Completed --> [*]
Failed --> [*]
```Result:
stateDiagram-v2
[*] --> Idle
Idle --> Running
Running --> Completed
Running --> Failed
Completed --> [*]
Failed --> [*]
```mermaid
classDiagram
class User {
+String name
+String email
+login()
}
class Admin {
+manageUsers()
}
User <|-- Admin
``````mermaid
gantt
title Project Timeline
section Planning
Requirements :done, 2024-01-01, 5d
Design :active, 2024-01-06, 7d
section Development
Implementation : 2024-01-13, 14d
```mermaidPlugin({
theme: 'dark' // or 'default', 'forest', 'neutral'
})mermaidPlugin({
theme: 'dark',
flowchart: {
curve: 'basis'
},
sequence: {
actorMargin: 50
}
})```mermaid
graph TB
subgraph "Client"
A[Browser]
end
subgraph "Server"
B[API]
C[Database]
end
A -->|HTTPS| B
B -->|Query| C
``````mermaid
flowchart LR
Input[Markdown] --> Parse[Parser]
Parse --> Transform[Plugin]
Transform --> Output[HTML]
```- Keep diagrams simple - Max 10-15 nodes for readability
- Use descriptive labels - Clear, concise text
- Group related nodes - Use subgraphs for organization
- Test rendering - Preview locally before committing
Mermaid adds ~250KB to bundle. For docs with many diagrams:
- Consider lazy loading
- Use static image exports for simple diagrams
- Limit diagrams per page
Prerequisites: Basic markdown knowledge, understanding of diagram types
Next Steps:
- Diagrams Guide - Visual architecture examples
Related:
- Mermaid.js Documentation - Complete syntax reference