Mermaid diagrams
Mermaid diagrams render client-side when the page loads. Toggle the light/dark theme switch to see diagram colors update automatically.
Fenced code block
Section titled “Fenced code block”Any fenced code block with the mermaid language tag renders as a diagram automatically. No import needed.
Explicit component
Section titled “Explicit component”Import <Mermaid> for more control. Pass the diagram source via the chart prop.
| Prop | Type | Required | Purpose |
|---|---|---|---|
chart | string | yes | Mermaid diagram definition. |
import Mermaid from '~/components/Mermaid.astro';
<Mermaid chart={`sequenceDiagram participant Browser participant Server Browser->>Server: GET /health Server-->>Browser: {"status":"ok"}`} />Live example
Section titled “Live example”More diagram types
Section titled “More diagram types”Flowchart
Section titled “Flowchart”Class diagram
Section titled “Class diagram”Error handling
Section titled “Error handling”Invalid mermaid syntax shows a styled error with the source and error message instead of breaking the page.