Theming
Mermaider uses a normalized CSS custom-property token system. Every diagram type reads from the same set of -- variables embedded in the SVG's <style> block, so changing colors once affects all diagram types uniformly.
| Token | Default | Role |
|---|---|---|
--bg |
#FFFFFF |
Canvas background |
--fg |
#27272A |
Primary text and strokes |
--accent |
#3b82f6 |
Arrow heads, active edges, highlights |
--muted |
derived | Secondary text, edge labels |
--surface |
derived | Node fill tint |
--border |
derived | Node and group strokes |
--line |
derived | Edge paths |
derived tokens are computed via color-mix(in srgb, var(--fg) X%, var(--bg)) — they automatically adapt when --fg and --bg are overridden. You rarely need to set them explicitly.
Pass any hex color or CSS value via RenderOptions:
var options = new RenderOptions
{
Bg = "#0D1117",
Fg = "#E6EDF3",
Accent = "#58A6FF",
};
string svg = MermaidRenderer.RenderSvg(diagram, options);
- dark background
- light text
- blue edges
Transparent defaults to true — the SVG has no background rectangle, so it inherits whatever is behind it. Set Transparent = false to fill the canvas with Bg:
var options = new RenderOptions { Transparent = false, Bg = "#FFFFFF" };
var options = new RenderOptions
{
Font = "Inter",
MonoFont = "JetBrains Mono",
FontSize = "0.9rem",
};
- proportional text
- code-style text (ER types, Class signatures)
- base size token --fs-m
MonoFont falls back to the system monospace stack when null. Font families must already be loaded in the host page — Mermaider does not embed web font @import rules in SVG output.
The type scale is derived from FontSize via fixed ratios you can override:
| Option | Ratio | Token |
|---|---|---|
FontSize |
1× | --fs-m |
FontSizeSmall |
0.875 | --fs-s |
FontSizeExtraSmall |
0.75 | --fs-xs |
FontSizeLarge |
1.125 | --fs-l |
Pie, sankey, timeline, radar, gitgraph, mindmap, venn, journey, packet, xychart, and treemap use a categorical color palette for series data. Override it with any array of CSS color strings:
var options = new RenderOptions
{
DataPalette = ["#7FE0FF", "#D66FFF", "#B6D9FF", "#E19BFF", "#4A8CFF"]
};
When null, the built-in palette is used.
var options = new RenderOptions
{
Padding = 40,
NodeSpacing = 28,
LayerSpacing = 48,
RoundedEdges = true,
};
- canvas padding in px
- horizontal gap between siblings
- vertical gap between layers
- 6px corner radius on edge paths