Mermaid mindmap theming fragility
Mermaid 11.4 mindmap diagrams ignore the standard themeVariables.
Setting mainBkg, nodeBorder, primaryColor, cScale0-cScale11,
cScaleLabel0-cScaleLabel11 does not change mindmap node fill or
label color. The mindmap module has its own render path that derives
colors from an internal palette generator.
How this was confirmed
On 2026-05-22 during the CortanaROI brain site Cortana-theme work:
-
Attempt 1: added
cScale0-11andcScaleLabel0-11overrides pinned to--lightgrayand--darkvia Codex. Verified the overrides made it into the deployedpostscript.jsbundle (curl + grep). Dark mode mindmap still showed white boxes with invisible labels. -
Attempt 2: added high-specificity CSS in
custom.scsstargeting[saved-theme="dark"] .mermaid svg foreignObject,.nodeLabel,.mindmap-node *with!important. Mermaid injects an inline<style>block inside the SVG with hex literals that tied or beat external CSS, and combining both attempts regressed light mode too. Rolled back. -
Resolution: replaced the
mindmapblock with aflowchart LRincontent/index.md. Flowcharts DO respectprimaryColor,mainBkg,nodeBorder, andprimaryTextColor. Both modes work immediately with no further hacks.
Rule
For any Quartz site (or any Mermaid render path with custom themes):
- Use
flowchart LRorgraph TDfor hierarchy diagrams, notmindmap. - Mermaid
flowcharthonors the standard themeVariables. Mermaidmindmapdoes not. - If a future Mermaid version (11.5+, 12.x) advertises mindmap theme support, re-test before adopting.
Adjacent fragility
- Mermaid label text inside
<foreignObject>is HTML, not SVG, sotext { fill }CSS never reaches it. Usecoloron the HTML selectors when you must override. - Mermaid versions pin breaking-API changes in minors (similar to Nautilus). Do not bump Mermaid without testing every diagram on the site.
Reference
- Mermaid CDN URL pinned in
quartz/components/scripts/mermaid.inline.ts:https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.4.0/mermaid.esm.min.mjs. - Cortana brain site commit
e79e099documents the swap.