Mermaid diagrams
Example showing how to use Comark with Mermaid diagrams in React and Vite.
Select a file to view its contents
Features
This example demonstrates how to use Comark with Mermaid diagrams in React:
- Mermaid Plugin: Import and configure the
mermaidplugin to parse mermaid code blocks - Mermaid Component: Register the
Mermaidcomponent to render diagrams as SVG - Multiple Diagram Types: Supports flowcharts, sequence diagrams, class diagrams, and all other Mermaid diagram types
- Configurable: Customize theme, width, and height via component props
Usage
Install dependencies:
npm install @comark/react beautiful-mermaidImport the mermaid plugin and component:
import { Comark } from '@comark/react' import mermaid, { Mermaid } from '@comark/react/plugins/mermaid'Pass the plugin and component to
Comark:<Comark markdown={content} components={{ Mermaid }} plugins={[mermaid()]} />Use mermaid code blocks in your markdown:
```mermaid graph TD A[Start] --> B[End] ```
Theme Support
Pass a theme via the code block info string:
```mermaid {theme='zinc-dark'}
sequenceDiagram
participant A
participant B
A->>B: Hello
```