# Mermaid Dark/Light Theme CSS snippet - adding contrast, providing template

**URL:** <https://forum.obsidian.md/t/mermaid-dark-light-theme-css-snippet-adding-contrast-providing-template/73147>\
**Category:** Themes & CSS snippets\
**Tags:** mermaid\
**Created:** [December 16, 2023, 1:06am UTC](https://forum.obsidian.md/t/mermaid-dark-light-theme-css-snippet-adding-contrast-providing-template/73147 "2023-12-16T01:06:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrcrl](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/bb73d2/32.png) [@adrcrl](https://forum.obsidian.md/u/adrcrl)\
**Post date:** [December 16, 2023, 1:06am UTC](https://forum.obsidian.md/t/mermaid-dark-light-theme-css-snippet-adding-contrast-providing-template/73147/1 "2023-12-16T01:06:56Z")

</div>

Hi all,  
I’d like to share my solution for a problem that I faced with Mermaid graphs in Obsidian - low contrast, hard to read, especially in dark theme. Please find below the css-snippet for Obsidian (Settings - Appearance - CSS Snippets).

```css
.mermaid svg {
	max-width: 100%;
	height: auto;
}

body.theme-light .mermaid .cluster rect
{
	stroke-width: 1px !important;
	stroke: var(--color-base-60) !important;
	fill: var(--color-base-05) !important;
} 
body.theme-light .mermaid .node * {
	stroke-width: 1px !important;
	stroke: var(--color-base-60) !important;
	fill: var(--color-base-25) !important;
}
body.theme-dark .mermaid .edgeLabel {
	background-color: var(--color-base-05) !important;
}

body.theme-dark .mermaid .cluster rect
{
	stroke-width: 1px !important;
	stroke: var(--color-base-60) !important;
	fill: var(--color-base-30) !important;
} 
body.theme-dark .mermaid .node * {
	stroke-width: 1px !important;
	stroke: var(--color-base-60) !important;
	fill: var(--color-base-20) !important;
}
body.theme-dark .mermaid .edgeLabel {
	background-color: var(--color-base-30) !important;
}

```

---

<div class="post-metadata">

**Author:** ![gstvcz](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gstvcz](https://forum.obsidian.md/u/gstvcz)\
**Post date:** [August 22, 2026, 6:12pm UTC](https://forum.obsidian.md/t/mermaid-dark-light-theme-css-snippet-adding-contrast-providing-template/73147/2 "2026-08-22T18:12:41Z")

</div>

**Hi, this script worked for me:**

```auto
.mermaid p,
.mermaid .venn-text-nodes span{
    background: transparent !important;
    color: #000 !important;
}

.mermaid .edgeLabel div,
.mermaid .edgeLabel span {
    background: transparent !important;
    background-color: transparent !important;
}

.mermaid .edgeLabel rect {
    fill: transparent !important;
    opacity: 0 !important; 
}

.mermaid path,
.mermaid line 
{    
    stroke: rgba(128, 128, 128, 0.8) !important;
}

```
