Component reference
MermaidDiagram
A Mermaid diagram drawn as themed SVG by Pele, with an optional title and a Copy source action.
Preview
Flow, sequence, chart and state
Mermaid source drawn as SVG by Pele on the library's roles: shapes lifted on the overlay rung with a hairline, groups a step below, connectors in tertiary ink, emphasis in the accent and charts in the shared series order. Switch the appearance to see the same diagrams in dark.
render: () => {
const steps = signal("flowchart TB\n A[Draft] --> B[Review]");
return (
<Specimens>
<Specimen label="Flowchart" width="content">
<MermaidDiagram
data-diagram="flowchart"
title="Release flow"
caption="From draft to publish"
source={release}
/>
</Specimen>
<Grid columns={2} gap="relaxed">
<Specimen label="Sequence">
<MermaidDiagram data-diagram="sequence" title="Review handshake" source={review} />
</Specimen>
<Specimen label="State">
<MermaidDiagram data-diagram="state" title="Change lifecycle" source={lifecycle} />
</Specimen>
</Grid>
<Grid columns={2} gap="relaxed">
<Specimen label="Pie" note="Slices take the shared chart series in order.">
<MermaidDiagram data-diagram="pie" source={usage} />
</Specimen>
<Specimen label="Bars and a line">
<MermaidDiagram data-diagram="xychart" source={weekly} />
</Specimen>
</Grid>
<Specimen label="Live source" note="A Signal source redraws in place." width="content">
<MermaidDiagram data-diagram="live" title="Steps so far" source={steps} />
<ActionRow>
<Button
variant="outline"
data-diagram-add-step
onClick={() => {
steps.value = `${steps.value}\n B --> C[Publish]`;
}}
>
Add the publish step
</Button>
</ActionRow>
</Specimen>
<Specimen
label="Over the size limit"
note="limits.source is 40 characters here."
width="content"
>
<MermaidDiagram data-diagram="limited" limits={{ source: 40 }} source={release} />
</Specimen>
<Specimen
label="Source that cannot be drawn"
note="The error and the source stay readable."
width="content"
>
<MermaidDiagram data-diagram="invalid" title="Broken" source={"flowchart LR\n A --> "} />
</Specimen>
</Specimens>
);
}Installation
Usage
Taken from the examples on this page.
import { MermaidDiagram } from "meowtail";
<MermaidDiagram title="Broken" source={"flowchart LR\n A --> "} />API reference
Before the client mounts it, and when the source cannot be drawn, it shows the source itself; links, images and icons inside diagrams are off, so untrusted text draws safely.
Props
| Prop | Type | Default |
|---|---|---|
sourceRequiredMermaid source. A Signal re-renders the diagram in place. | MaybeSignal<string> | – |
titleThe diagram's name at the start of the header. A plain value is fixed for the mount. | MaybeSignal<Child> | – |
captionA quiet supporting line for the name. A plain value is fixed for the mount. | MaybeSignal<Child> | – |
actionsHost buttons or links; they render before the built-in Copy source action. | MaybeSignal<Child> | – |
zoomZoom and pan controls: "auto" shows them only when the diagram is larger than its frame. Fixed for the mount. | boolean | "auto" | "auto" |
limitsTighter or looser bounds than the defaults (50,000 source characters, 2,000 edges). | MermaidDiagramLimits | – |
onCopyHosts may supply a clipboard implementation; the default uses the browser clipboard. | (source: string) => Promise<void> | – |
Also takes className, children and the attributes and events of its root element.
DOM parts
Registry
The component is registered as mermaid-diagram in the meowtail component registry.