Skip to content

Mermaid diagrams

Mermaid diagrams render client-side when the page loads. Toggle the light/dark theme switch to see diagram colors update automatically.

Any fenced code block with the mermaid language tag renders as a diagram automatically. No import needed.

Import <Mermaid> for more control. Pass the diagram source via the chart prop.

PropTypeRequiredPurpose
chartstringyesMermaid diagram definition.
import Mermaid from '~/components/Mermaid.astro';
<Mermaid chart={`
sequenceDiagram
participant Browser
participant Server
Browser->>Server: GET /health
Server-->>Browser: {"status":"ok"}
`} />

Invalid mermaid syntax shows a styled error with the source and error message instead of breaking the page.

Built with rosetta-template