Skip to content

Themes

Customize the look of animated diagrams with CSS custom properties. Each <mermaid-flow-player> can be styled independently.

Each theme is just CSS custom properties scoped to a container:

No extra CSS needed — uses built-in defaults.

<mermaid-flow-player>
<pre class="mermaid">graph LR; A-->B-->C</pre>
</mermaid-flow-player>

With theme attribute:

<script src="https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest/mermaid-flow-player.element.js"></script>
<!-- Light theme (default) -->
<mermaid-flow-player controls theme="light">
graph LR; A-->B-->C
</mermaid-flow-player>
<!-- Dark theme -->
<mermaid-flow-player controls theme="dark">
graph LR; A-->B-->C
</mermaid-flow-player>
<!-- Auto theme (follows system preference) -->
<mermaid-flow-player controls theme="auto">
graph LR; A-->B-->C
</mermaid-flow-player>
.dark-theme {
--mf-control-bg: #2a2a2a;
--mf-control-border: #444;
--mf-control-text: #e0e0e0;
--mf-control-hover-bg: #3a3a3a;
--mf-narration-bg: #1e1e1e;
--mf-narration-text: #ccc;
}
.ocean-theme {
--mf-control-bg: #e3f2fd;
--mf-control-border: #90caf9;
--mf-control-text: #0d47a1;
--mf-control-hover-bg: #bbdefb;
--mf-narration-bg: #e8f5e9;
--mf-narration-text: #1b5e20;
}
<mermaid-flow-player style="
--mf-control-bg: #fff3e0;
--mf-control-text: #e65100;
">
<pre class="mermaid">graph LR; A-->B</pre>
</mermaid-flow-player>
VariableDefaultDescription
--mf-active-color#4caf50Active node highlight
--mf-visited-color#2196f3Visited node color
--mf-active-stroke#3b82f6Active node/edge stroke color
--mf-active-stroke-width3pxActive node/edge stroke width
--mf-visited-stroke#3b82f6Visited node/edge stroke color
--mf-visited-stroke-width2pxVisited node/edge stroke width
--mf-visited-opacity1Visited node opacity
--mf-transition-duration220msAnimation transition speed
--mf-control-bg#f5f5f5Button background
--mf-control-border#dddButton border
--mf-control-text#333Button text color
--mf-control-hover-bg#e0e0e0Button hover background
--mf-control-border-radius4pxButton corner radius
--mf-control-padding8px 16pxButton padding
--mf-control-gap8pxGap between controls
--mf-narration-bg#f0f0f0Narration bar background
--mf-narration-text#333Narration text color
--mf-narration-padding10pxNarration padding
--mf-narration-font-size14pxNarration font size

Themes persist across page loads via localStorage:

import { initTheme } from 'mermaid-flow-player';
initTheme({ theme: 'auto' }); // follows prefers-color-scheme

Set theme via URL query parameter:

https://your-site.com/diagrams?theme=dark

See Query Parameters for more.