Mermaid
Purpose: Visual diagramming tool for creating flowcharts, sequence diagrams, architecture diagrams, and more in Docusaurus documentation.
Last verified: December 2025
Overview
Mermaid is a diagramming and charting tool that uses text-based syntax to create diagrams. Docusaurus supports Mermaid diagrams via @docusaurus/theme-mermaid and can be used in any Markdown file.
Viewing Mermaid Diagrams in Cursor
Mermaid diagrams are supported in Cursor's markdown preview, but require an extension to render properly.
Installation
To view Mermaid diagrams in Cursor's markdown preview:
- Open the Extensions tab (
Cmd+Shift+Xon macOS,Ctrl+Shift+Xon Windows/Linux) - Search for "Markdown Preview Mermaid Support"
- Install the extension by bierner (Matt Bierner)
- After installation, Mermaid diagrams will render as visual diagrams in preview mode
Usage
Once the extension is installed:
- Open a markdown file containing Mermaid diagrams
- Switch to preview mode (
Cmd+Shift+Von macOS,Ctrl+Shift+Von Windows/Linux) - Mermaid code blocks will render as visual diagrams instead of raw syntax
Note: The extension is required for Mermaid rendering in Cursor. Without it, Mermaid code blocks will display as plain text in preview mode.
For more details, see the Cursor documentation on Mermaid diagrams.
Usage
Add Mermaid diagrams using code blocks with the mermaid language:
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
Diagram Types
Quick navigation to all diagram types:
Basic Diagrams: Flowcharts • Sequence Diagrams • Class Diagrams • State Diagrams • Entity Relationship Diagrams
Charts & Visualizations: Gantt Charts • Pie Charts • User Journey • Quadrant Chart • Radar Diagrams • Treemap Diagrams
Specialized Diagrams: Requirement Diagram • GitGraph • C4 Diagrams • Mindmaps • Timeline
Flow & Process: Sankey Diagrams • Block Diagrams • Kanban Diagrams • Architecture Diagrams
Experimental: ZenUML • XY Chart • Packet Diagram
Flowcharts
Description: Flowcharts are the most basic and commonly used diagram type in Mermaid. They represent processes, workflows, or algorithms using nodes and connections.
Use Cases:
- Process flows and workflows
- Decision trees and algorithms
- System architecture overviews
- Business process documentation
- User journey flows
Nuances:
- Supports multiple directions:
TD/TB(top-down),BT(bottom-up),LR(left-right),RL(right-left) - Various node shapes: rectangles, diamonds (decisions), circles, cylinders (databases), etc.
- Can use subgraphs to group related nodes
- Automatic layout by default (Dagre algorithm), or ELK layout for complex diagrams
- Supports styling with CSS classes and inline styles
Syntax:
Sequence Diagrams
Description: Sequence diagrams show interactions between objects or components over time, displaying the order of messages exchanged.
Use Cases:
- API interactions and request/response flows
- System component communication
- User interaction flows
- Database transaction sequences
- Microservice communication patterns
Nuances:
- Participants are defined at the start and can be actors, systems, or components
- Supports loops, alt/else blocks, and notes
- Arrow types indicate message direction:
->>(solid),-->>(dashed) - Activation boxes show when a participant is active
- Can include notes on the left or right of participants
Syntax:
Class Diagrams
Description: Class diagrams represent the structure of object-oriented systems, showing classes, their attributes, methods, and relationships.
Use Cases:
- Object-oriented system design
- Database schema design
- API structure documentation
- Code architecture visualization
- Inheritance and composition relationships
Nuances:
- Supports classes, interfaces, and abstract classes
- Shows relationships: inheritance (
<|--), composition (*--), aggregation (o--), association (-->) - Can include visibility modifiers:
+(public),-(private),#(protected) - Supports generic types and annotations
- Can group classes into packages or namespaces
Syntax:
State Diagrams
Description: State diagrams (also called state machines) show the different states an object or system can be in and the transitions between them.
Use Cases:
- System state management
- Workflow state transitions
- User interface state flows
- Process lifecycle documentation
- Game state machines
Nuances:
- States can be simple, composite (nested), or concurrent
- Transitions can have guards, events, and actions
- Supports history states (shallow and deep)
- Can define initial and final states
- Supports fork and join for concurrent states
Syntax:
Entity Relationship Diagrams
Description: ER diagrams visualize the structure of databases, showing entities (tables), their attributes (columns), and relationships between them.
Use Cases:
- Database schema design
- Data modeling
- Database documentation
- Relationship mapping
- Data architecture planning
Nuances:
- Entities are represented as rectangles with attributes listed inside
- Relationships show cardinality:
||--||(one-to-one),||--o{(one-to-many),}o--o{(many-to-many) - Attributes can be marked as keys, required, or optional
- Supports weak entities and identifying relationships
- Can show attribute types and constraints
Syntax:
Gantt Charts
Description: Gantt charts are project management tools that visualize project schedules, showing tasks, their durations, dependencies, and milestones over time.
Use Cases:
- Project planning and scheduling
- Resource allocation
- Timeline visualization
- Milestone tracking
- Sprint planning
Nuances:
- Tasks can be marked as
done,active, orcrit(critical path) - Supports task dependencies using
afterkeyword - Can exclude specific dates (e.g., weekends, holidays)
- Supports sections to group related tasks
- Date format is configurable (YYYY-MM-DD by default)
- Can show progress percentages and task priorities
Syntax:
Pie Charts
Description: Pie charts display proportional data as slices of a circle, where each slice's size represents its proportion of the whole.
Use Cases:
- Budget allocation visualization
- Market share representation
- Survey results
- Category distribution
- Resource allocation breakdown
Nuances:
- Values are automatically calculated as percentages
- Supports up to 12 different slices with automatic color assignment
- Can include a title and legend
- Values can be displayed as percentages or raw numbers
- Supports custom styling for individual slices
Syntax:
User Journey
Description: User journey diagrams map out the steps a user takes to accomplish a goal, showing their experience across different stages and touchpoints.
Use Cases:
- Customer experience mapping
- User onboarding flows
- Product usage journeys
- Service design
- UX research documentation
Nuances:
- Organized into sections representing different stages
- Each step has a score (1-5) indicating satisfaction or importance
- Can include multiple actors (users, systems, etc.)
- Supports rich text descriptions for each step
- Automatically uses different colors for different sections
Syntax:
Quadrant Chart
Description: Quadrant charts (also called 2x2 matrices) plot items on a two-dimensional grid divided into four quadrants, useful for prioritization and strategic planning.
Use Cases:
- Feature prioritization (impact vs effort)
- Risk assessment (probability vs impact)
- Strategic planning matrices
- Campaign analysis (reach vs engagement)
- Technology evaluation
Nuances:
- X and Y axes are configurable with custom labels
- Each quadrant can have a descriptive label
- Points are plotted using
[x, y]coordinates (0.0 to 1.0) - Supports custom quadrant labels and colors
- Useful for Eisenhower matrix, BCG matrix, and similar frameworks
Syntax:
Requirement Diagram
Description: Requirement diagrams document system requirements and their relationships to system elements, showing how requirements are satisfied by design elements.
Use Cases:
- Requirements traceability
- System design documentation
- Compliance mapping
- Quality assurance planning
- Requirements validation
Nuances:
- ⚠️ Experimental Feature: Requirement diagrams are experimental and may not work in all Mermaid versions. If you encounter errors, use a flowchart diagram instead.
- Requirements can have properties:
id,text,risk,verifymethod,owner - Elements can be functional or technical
- Relationships show how requirements are satisfied by elements
- Supports risk levels and verification methods
Note: Due to parsing issues with requirement diagrams in some Mermaid versions, the examples below may not render correctly. Consider using a flowchart diagram as an alternative for requirements documentation.
Example - Tracking & Analytics Requirements:
Note: Requirement diagrams are currently experimental and have parsing issues in Mermaid. Use the flowchart alternative shown above for requirements documentation.
GitGraph (Git) Diagram
Description: GitGraph diagrams visualize Git branching workflows, showing commits, branches, merges, and the history of a repository.
Use Cases:
- Git workflow documentation
- Branching strategy visualization
- Release process documentation
- Code review process flows
- Team collaboration patterns
Nuances:
- Note: If GitGraph doesn't render, ensure you're using a recent version of Mermaid that supports git diagrams.
- Commits are created with
commit id: "message" - Branches are created with
branch nameand switched withcheckout name - Merges are performed with
merge branchName - Supports tags, cherry-picks, and rebases
- Can show commit messages and branch labels
Syntax:
C4 Diagrams
Description: C4 diagrams model software architecture at different levels of abstraction (Context, Container, Component, Code), following the C4 model for visualizing software systems.
Use Cases:
- Software architecture documentation
- System design communication
- Technical documentation
- Architecture decision records
- System context visualization
Nuances:
- ⚠️ Experimental Feature: C4 diagrams are experimental. The syntax and properties can change in future releases. Mermaid's C4 diagram syntax is compatible with PlantUML.
- Five diagram types: System Context, Container, Component, Dynamic, and Deployment
- Uses fixed styling (CSS colors), so themes don't affect appearance
- Layout is semi-automatic based on statement order
- Supports boundaries (Enterprise, System, Container) to group elements
- Can customize element and relationship styles with
UpdateElementStyleandUpdateRelStyle
C4 diagrams are used to visualize software architecture at different levels of abstraction. Five types of C4 charts are supported:
- System Context (C4Context) - High-level view showing the system and its relationships with users and other systems
- Container diagram (C4Container) - Shows containers (applications, data stores, etc.) within a system
- Component diagram (C4Component) - Shows components within a container
- Dynamic diagram (C4Dynamic) - Shows the flow of data or control between components
- Deployment diagram (C4Deployment) - Shows how containers are deployed to infrastructure
Example - System Context Diagram:
Example - Container Diagram:
Key Syntax Elements:
Person(alias, label, ?descr)- Represents a person/userSystem(alias, label, ?descr)- Represents a systemSystem_Ext(alias, label, ?descr)- External systemContainer(alias, label, ?techn, ?descr)- Application containerContainerDb(alias, label, ?techn, ?descr)- Database containerRel(from, to, label, ?techn)- Relationship between elementsBiRel(from, to, label)- Bidirectional relationshipUpdateElementStyle(element, $bgColor, $fontColor, $borderColor)- Customize element stylingUpdateRelStyle(from, to, $textColor, $lineColor, $offsetX, $offsetY)- Customize relationship styling
Note: C4 diagrams use fixed styling (CSS colors), so different themes don't affect them. The layout is semi-automatic based on the order of statements. For complete syntax reference, see the C4-PlantUML documentation.
Mindmaps
Description: Mindmaps are hierarchical diagrams that organize information around a central concept, with branches representing related ideas or subtopics.
Use Cases:
- Brainstorming and idea organization
- Knowledge mapping
- Project planning
- Study notes
- Concept visualization
Nuances:
- Starts with a root node (usually in double parentheses)
- Uses indentation to create hierarchy
- Automatically arranges nodes in a radial layout
- Supports multiple levels of nesting
- Can include icons and emojis in node labels
Syntax:
Timeline
Description: Timeline diagrams display events, milestones, or activities in chronological order, showing when things happened or will happen.
Use Cases:
- Project timelines
- Historical event documentation
- Release planning
- Roadmap visualization
- Event scheduling
Nuances:
- Organized by time periods (years, quarters, months, etc.)
- Each period can have multiple events listed with indentation
- Supports titles and descriptions for each event
- Can show parallel timelines or multiple tracks
- Useful for showing project phases and milestones
Syntax:
ZenUML
Description: ZenUML-style sequence diagrams provide an alternative syntax for sequence diagrams, though this is not standard Mermaid syntax.
Use Cases:
- Alternative sequence diagram syntax
- Simplified interaction documentation
- API flow documentation
Nuances:
- ⚠️ Note: ZenUML is a separate tool, not standard Mermaid. Use sequence diagrams instead for similar functionality.
- Uses arrow notation:
->for synchronous,-->for return - More compact syntax than standard sequence diagrams
- Not officially supported in Mermaid - use standard sequence diagrams for compatibility
Syntax (using Sequence Diagram instead):
Sankey Diagrams
Description: Sankey diagrams visualize flow or transfer between nodes, where the width of the connections represents the quantity or magnitude of flow.
Use Cases:
- Energy flow visualization
- Data flow analysis
- Resource allocation tracking
- Website traffic flow
- Process flow with quantities
Nuances:
- ⚠️ Experimental Feature (v10.3.0+): Sankey diagrams are experimental. The syntax is very close to plain CSV but may be extended in the future.
- Uses CSV format:
source,target,value(three columns) - Supports empty lines for visual spacing
- Link colors can be set to
source,target,gradient, or a hex color - Node alignment options:
justify,center,left,right - Configurable width, height, and visual styling
A Sankey diagram visualizes flow from one set of values to another. The things being connected are called nodes and the connections are called links.
Example:
Syntax:
The syntax uses CSV format with 3 columns: source,target,value
CSV Features:
- Empty lines: Allowed for visual purposes (without comma separators)
- Commas in text: Wrap in double quotes:
"Heating and cooling, homes",193.026 - Double quotes in text: Use pairs:
"Heating and cooling, ""homes""",193.026
Configuration Options:
sankey: {
width: 800,
height: 400,
linkColor: 'source', // 'source', 'target', 'gradient', or hex color
nodeAlignment: 'left', // 'justify', 'center', 'left', 'right'
}
Link Coloring:
source- Link uses source node colortarget- Link uses target node colorgradient- Smooth transition between source and target colors- Hex color code (e.g.,
#a1a1a1)
Node Alignment:
justify- Distribute nodes evenlycenter- Center nodesleft- Align nodes to the leftright- Align nodes to the right
XY Chart
Description: XY charts (also called Cartesian charts) plot data points on X and Y axes, supporting both bar and line chart types in a single diagram.
Use Cases:
- Time series data visualization
- Sales trends
- Performance metrics over time
- Comparative data analysis
- Multi-series data plotting
Nuances:
- ⚠️ Beta Feature: XY charts are in beta and may not be available in all Mermaid versions. Use a Gantt chart or external charting library if this doesn't render.
- Supports both bar and line chart types simultaneously
- X-axis can be categorical (labels) or numeric
- Y-axis is numeric with configurable range
- Can display multiple data series
- Useful for showing trends and comparisons over time
Syntax (using Gantt chart as alternative if XY Chart doesn't render):
Block Diagrams
Description: Block diagrams provide full control over block positioning, unlike flowcharts which use automatic layout. They're ideal for representing complex systems where precise positioning matters.
Use Cases:
- Software architecture with specific layouts
- Network diagrams
- Process flowcharts with custom positioning
- System design with spatial relationships
- Educational diagrams requiring precise placement
Nuances:
- Author has full control over block positions (unlike automatic flowchart layout)
- Supports multiple columns and custom block widths
- Various block shapes: rectangles, circles, cylinders, diamonds, etc.
- Can create composite blocks (blocks within blocks)
- Supports block arrows and space blocks for layout control
- Useful when automatic layout doesn't produce desired results
Basic Structure:
Multi-Column Layout:
Example - System Architecture:
Key Features:
- Column Control: Define number of columns with
columns N - Block Width: Span multiple columns with
blockId:width(e.g.,a:2spans 2 columns) - Composite Blocks: Nest blocks within blocks using
block:groupId:width...end - Block Shapes: Various shapes available:
id["Label"]- Rectangle (default)id("Label")- Round edgesid(["Label"])- Stadium shapeid[["Label"]]- Subroutineid[("Label")]- Cylindrical (database)id(("Label"))- Circleid>"Label"]- Asymmetricid{"Label"}- Rhombus (decision)id{{"Label"}}- Hexagonid[/"Label"/]- Parallelogramid[\"Label"\]]- Trapezoid
Block Arrows:
Space Blocks:
Connecting Blocks:
Styling:
Class Styling:
Packet Diagram
Description: Packet diagrams visualize the structure of network packets, showing the layout of headers, fields, and data segments in network protocols.
Use Cases:
- Network protocol documentation
- Packet structure visualization
- Network engineering documentation
- Protocol analysis
- Educational network diagrams
Nuances:
- ⚠️ Beta Feature: Packet diagrams are in beta and may not be available. Use a flowchart or table to represent packet structure if this doesn't render.
- Shows bit ranges and field names (e.g.,
0-15: Source Port) - Useful for TCP/IP, UDP, and other protocol documentation
- Can represent packet headers and data segments
- Alternative: Use flowcharts or tables if this diagram type doesn't render
Syntax (using Packet Diagram):
Kanban Diagrams
Description: Kanban diagrams visualize tasks moving through different stages of a workflow, similar to physical Kanban boards used in agile project management.
Use Cases:
- Project management and task tracking
- Sprint planning and backlog management
- Workflow visualization
- Team task organization
- Agile development boards
Nuances:
- Columns represent workflow stages (e.g., Todo, In Progress, Done)
- Tasks are listed under their respective columns
- Supports task metadata:
assigned,ticket,priority(Very High, High, Low, Very Low) - Can configure
ticketBaseUrlfor clickable ticket links - Proper indentation is crucial - tasks must be indented under columns
- Each column and task needs a unique identifier
Basic Syntax:
Defining Columns:
Columns represent workflow stages. Each column needs a unique identifier and title:
Adding Tasks:
Tasks are listed under their respective columns with indentation:
Task Metadata:
Add metadata to tasks using @{ ... } syntax:
Supported Metadata Keys:
assigned- Who is responsible for the taskticket- Links to a ticket or issue numberpriority- Task urgency:'Very High','High','Low','Very Low'
Full Example with Metadata:
Configuration:
Set ticketBaseUrl in the config block to create clickable ticket links:
---
config:
kanban:
ticketBaseUrl: 'https://yourproject.atlassian.net/browse/#TICKET#'
---
The #TICKET# placeholder is replaced with the ticket value from task metadata.
Important Notes:
- Proper indentation is crucial - tasks must be indented under their parent columns
- Each column and task needs a unique identifier
- Column titles can be written as
columnId[Title]or just[Title](auto-generated ID)
Architecture Diagrams
Description: Architecture diagrams visualize cloud and CI/CD infrastructure, showing services, resources, and their relationships in deployment environments.
Use Cases:
- Cloud infrastructure documentation
- CI/CD pipeline visualization
- Microservices architecture
- Deployment architecture
- System resource mapping
Nuances:
- ⚠️ Beta Feature (v11.1.0+): Architecture diagrams are used to show relationships between services and resources commonly found within Cloud or CI/CD deployments.
- Consists of groups, services, edges, and junctions
- Default icons:
cloud,database,disk,internet,server - Can use custom icons from iconify.design by registering icon packs
- Edge directions specified with
L(left),R(right),T(top),B(bottom) - Supports arrows on edges and group boundaries
- Junctions allow 4-way connections between services
Architecture diagrams consist of groups, services, edges, and junctions. Services are connected by edges, and related services can be placed within groups.
Example:
Groups:
Groups organize related services. Syntax: group {group id}({icon name})[{title}] (in {parent id})?
Services:
Services represent individual components. Syntax: service {service id}({icon name})[{title}] (in {parent id})?
Default Icons:
cloud- Cloud servicedatabase- Databasedisk- Storage/diskinternet- Internet/gatewayserver- Server
Custom Icons:
You can use any icon from iconify.design by registering an icon pack and using name:icon-name format:
Edges:
Edges connect services. Syntax: {serviceId}{{group}}?:{T|B|L|R} {<}?--{>}? {T|B|L|R}:{serviceId}{{group}}?
Edge Direction:
Specify which side of the service the edge connects to using L (left), R (right), T (top), or B (bottom):
Arrows:
Add arrows with < (left side) and/or > (right side):
Edges from Groups:
Use {group} modifier to create edges from group boundaries:
Junctions:
Junctions act as 4-way connection points:
Radar Diagrams
Description: Radar diagrams (also known as spider charts, star charts, or polar charts) plot multi-dimensional data in a circular format, with each axis representing a different dimension.
Use Cases:
- Performance comparison across multiple metrics
- Skills assessment
- Product feature comparison
- Quality evaluation
- Multi-criteria decision analysis
Nuances:
- ⚠️ Beta Feature (v11.6.0+): Radar diagrams plot low-dimensional data in a circular format.
- Axes are defined with
axiskeyword and can have custom labels - Curves represent different entities being compared
- Values can be specified as lists
{1,2,3}or key-value pairs{axis1: 10, axis2: 20} - Supports
maxandminfor scaling - Graticule can be
circle(default) orpolygon - Configurable ticks, margins, and curve styling
- Supports theme variables for colors (
cScale0throughcScale11)
Example:
Syntax:
Key Elements:
- title: Optional title at the top of the diagram
- axis: Define axes with ID and optional label. Multiple axes can be defined:
axis id1["Label1"], id2["Label2"] - curve: Define data points. Values can be a list
{1, 2, 3}or key-value pairs{axis3: 30, axis1: 20} - max/min: Scale the diagram (default min is 0)
- graticule:
circle(default) orpolygon - ticks: Number of concentric circles/polygons (default: 5)
- showLegend: Show or hide legend (default: true)
Configuration Options:
---
config:
radar:
width: 600
height: 600
marginTop: 50
marginBottom: 50
marginLeft: 50
marginRight: 50
axisScaleFactor: 1
axisLabelFactor: 1.05
curveTension: 0.17
themeVariables:
radar:
axisColor: "#000000"
axisStrokeWidth: 1
axisLabelFontSize: 12
curveOpacity: 0.7
curveStrokeWidth: 2
graticuleColor: "#000000"
graticuleOpacity: 0.5
graticuleStrokeWidth: 1
legendBoxSize: 10
legendFontSize: 14
---
Theme Variables:
Radar charts support color scales cScale${i} (where i is 0-11) for curve colors. Set these in themeVariables:
themeVariables:
cScale0: "#FF0000"
cScale1: "#00FF00"
cScale2: "#0000FF"
Treemap Diagrams
Description: Treemap diagrams display hierarchical data as nested rectangles, where each rectangle's size is proportional to its value, making it easy to compare proportions across categories.
Use Cases:
- Budget allocation visualization
- File system disk usage
- Market share analysis
- Portfolio composition
- Hierarchical data with size relationships
Nuances:
- ⚠️ Beta Feature: Treemap diagrams display hierarchical data as nested rectangles.
- Hierarchy created using indentation (spaces or tabs)
- Section/parent nodes:
"Section Name" - Leaf nodes with values:
"Leaf Name": value - Supports styling with
:::classsyntax - Value formatting: supports D3 format specifiers (
,,$,.1f,.1%, etc.) - Configurable padding, node sizes, font sizes, and borders
- Works best with natural hierarchies and positive values
- Very small values may be difficult to see
Basic Example:
Hierarchical Example - Tool Usage Breakdown:
Syntax:
- Section/Parent nodes:
"Section Name" - Leaf nodes with values:
"Leaf Name": value - Hierarchy: Created using indentation (spaces or tabs)
- Styling: Use
:::classsyntax for custom styling
Styling with Classes:
Configuration Options:
---
config:
treemap:
useMaxWidth: true
padding: 10
diagramPadding: 8
showValues: true
nodeWidth: 100
nodeHeight: 40
borderWidth: 1
valueFontSize: 12
labelFontSize: 14
valueFormat: ',' # Thousands separator
---
Value Formatting:
The valueFormat option supports D3 format specifiers:
,- Thousands separator (default)$- Add dollar sign.1f- One decimal place.1%- Percentage with one decimal$0,0- Dollar sign with thousands separator$.2f- Dollar sign with 2 decimal places
Example with Currency Formatting:
Use Cases:
- Financial data (budget allocations, market shares)
- File system analysis (disk space usage)
- Population demographics
- Product hierarchies and sales volumes
- Organizational structures
Limitations:
- Works best with natural hierarchies
- Very small values may be difficult to see
- Deep hierarchies can be challenging
- Not suitable for negative values
Styling and Customization
Node Styling
Syntax:
Subgraphs
Syntax:
Flowchart Direction
TDorTB- Top to Bottom (default)BT- Bottom to TopLR- Left to RightRL- Right to Left
Node Shapes
A[Text]- Rectangle (default)A(Rounded)- Rounded rectangleA{Decision}- Diamond (decision)A((Circle))- CircleA([Stadium])- Stadium shapeA[[Subroutine]]- SubroutineA[(Database)]- CylinderA>Parallelogram]- Parallelogram
Arrow Types
A-->B- Solid arrowA---B- Solid line (no arrow)A-.->B- Dotted arrowA-.-B- Dotted lineA==>B- Thick arrowA==B- Thick lineA--|label|-->B- Arrow with labelA-.|label|.->B- Dotted arrow with label
Configuration
Mermaid themes are configured in docusaurus.config.ts. The Pacing Tech Stack site uses a custom theme based on the base theme with Pacing brand colours that work well in both light and dark modes.
Current Configuration:
themeConfig: {
mermaid: {
theme: {
light: 'base',
dark: 'base',
},
themeVariables: {
// Light mode colours
primaryColor: '#e1f5ff',
primaryTextColor: '#01579b',
primaryBorderColor: '#0277bd',
secondaryColor: '#f3e5f5',
tertiaryColor: '#e8f5e9',
// ... additional theme variables
},
darkThemeVariables: {
// Dark mode colours
primaryColor: '#01579b',
primaryTextColor: '#e1f5ff',
// ... dark mode overrides
},
options: {
maxTextSize: 50000,
},
},
},
Customising Individual Diagrams:
You can override the theme for specific diagrams using frontmatter:
```mermaid
---
config:
theme: 'base'
themeVariables:
primaryColor: '#BB2528'
primaryTextColor: '#fff'
---
graph TD
A --> B
```
Available Built-in Themes:
default- Default Mermaid themeneutral- Great for black and white documentsdark- Works well with dark-coloured elementsforest- Contains shades of greenbase- The only theme that can be fully customised (used in this site)
Best Practices
- Keep diagrams simple: Complex diagrams can be hard to read. Break large diagrams into smaller, focused ones.
- Use meaningful labels: Clear labels make diagrams self-documenting.
- Consistent styling: Use consistent colours and styles across related diagrams.
- Test rendering: Always preview diagrams locally before committing.
- Accessibility: Ensure diagrams are readable in both light and dark modes.
Dynamic Mermaid Component
For dynamic diagrams (e.g., with user input), use the Mermaid component:
import Mermaid from '@theme/Mermaid';
<Mermaid
value={`graph TD;
A-->B;
A-->C;
B-->D;
C-->D;`}
/>
Resources
- Mermaid Live Editor - Test diagrams before adding to docs
- Mermaid Documentation - Complete syntax reference
- Docusaurus Mermaid Docs - Docusaurus-specific guidance
Related Documentation
- Docusaurus setup: See Docusaurus
- Source files:
tools/,architecture.md,README.md - Docusaurus README:
docusaurus/README.md