Skip to content

Instantly share code, notes, and snippets.

@myl7
Last active June 15, 2024 10:41
Show Gist options
  • Save myl7/c93d000876ec76da8d23b0ccc9cbcb6e to your computer and use it in GitHub Desktop.
Save myl7/c93d000876ec76da8d23b0ccc9cbcb6e to your computer and use it in GitHub Desktop.
CSS to make Mermaid SVG charts automatically switch to light/dark mode based on class `dark` of parents
#graph-div {
font-family: 'trebuchet ms', verdana, arial, sans-serif;
font-size: 16px;
fill: #333;
}
#graph-div .error-icon {
fill: #552222;
}
#graph-div .error-text {
fill: #552222;
stroke: #552222;
}
#graph-div .edge-thickness-normal {
stroke-width: 2px;
}
#graph-div .edge-thickness-thick {
stroke-width: 3.5px;
}
#graph-div .edge-pattern-solid {
stroke-dasharray: 0;
}
#graph-div .edge-pattern-dashed {
stroke-dasharray: 3;
}
#graph-div .edge-pattern-dotted {
stroke-dasharray: 2;
}
#graph-div .marker {
fill: #333333;
stroke: #333333;
}
#graph-div .marker.cross {
stroke: #333333;
}
#graph-div svg {
font-family: 'trebuchet ms', verdana, arial, sans-serif;
font-size: 16px;
}
#graph-div .label {
font-family: 'trebuchet ms', verdana, arial, sans-serif;
color: #333;
}
#graph-div .cluster-label text {
fill: #333;
}
#graph-div .cluster-label span,
#graph-div p {
color: #333;
}
#graph-div .label text,
#graph-div span,
#graph-div p {
fill: #333;
color: #333;
}
#graph-div .node rect,
#graph-div .node circle,
#graph-div .node ellipse,
#graph-div .node polygon,
#graph-div .node path {
fill: #ececff;
stroke: #9370db;
stroke-width: 1px;
}
#graph-div .flowchart-label text {
text-anchor: middle;
}
#graph-div .node .katex path {
fill: #000;
stroke: #000;
stroke-width: 1px;
}
#graph-div .node .label {
text-align: center;
}
#graph-div .node.clickable {
cursor: pointer;
}
#graph-div .arrowheadPath {
fill: #333333;
}
#graph-div .edgePath .path {
stroke: #333333;
stroke-width: 2px;
}
#graph-div .flowchart-link {
stroke: #333333;
fill: none;
}
#graph-div .edgeLabel {
background-color: #e8e8e8;
text-align: center;
}
#graph-div .edgeLabel rect {
opacity: 0.5;
background-color: #e8e8e8;
fill: #e8e8e8;
}
#graph-div .labelBkg {
background-color: rgba(232, 232, 232, 0.5);
}
#graph-div .cluster rect {
fill: #ffffde;
stroke: #aaaa33;
stroke-width: 1px;
}
#graph-div .cluster text {
fill: #333;
}
#graph-div .cluster span,
#graph-div p {
color: #333;
}
#graph-div div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: 'trebuchet ms', verdana, arial, sans-serif;
font-size: 12px;
background: hsl(80, 100%, 96.2745098039%);
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
#graph-div .flowchartTitleText {
text-anchor: middle;
font-size: 18px;
fill: #333;
}
#graph-div :root {
--mermaid-font-family: 'trebuchet ms', verdana, arial, sans-serif;
}
/* Dark mode */
.dark #graph-div {
fill: #ccc;
}
.dark #graph-div .error-icon {
fill: #a44141;
}
.dark #graph-div .error-text {
fill: #ddd;
stroke: #ddd;
}
.dark #graph-div .marker {
fill: lightgrey;
stroke: lightgrey;
}
.dark #graph-div .marker.cross {
stroke: lightgrey;
}
.dark #graph-div .label {
color: #ccc;
}
.dark #graph-div .cluster-label text {
fill: #f9fffe;
}
.dark #graph-div .cluster-label span,
.dark #graph-div p {
color: #f9fffe;
}
.dark #graph-div .label text,
.dark #graph-div span,
.dark #graph-div p {
fill: #ccc;
color: #ccc;
}
.dark #graph-div .node rect,
.dark #graph-div .node circle,
.dark #graph-div .node ellipse,
.dark #graph-div .node polygon,
.dark #graph-div .node path {
fill: #1f2020;
stroke: #81b1db;
}
.dark #graph-div .arrowheadPath {
fill: lightgrey;
}
.dark #graph-div .edgePath .path {
stroke: lightgrey;
}
.dark #graph-div .flowchart-link {
stroke: lightgrey;
}
.dark #graph-div .edgeLabel {
background-color: hsl(0, 0%, 34.4117647059%);
}
.dark #graph-div .edgeLabel rect {
background-color: hsl(0, 0%, 34.4117647059%);
fill: hsl(0, 0%, 34.4117647059%);
}
.dark #graph-div .labelBkg {
background-color: rgba(87.75, 87.75, 87.75, 0.5);
}
.dark #graph-div .cluster rect {
fill: hsl(180, 1.5873015873%, 28.3529411765%);
stroke: rgba(255, 255, 255, 0.25);
}
.dark #graph-div .cluster text {
fill: #f9fffe;
}
.dark #graph-div .cluster span,
.dark #graph-div p {
color: #f9fffe;
}
.dark #graph-div div.mermaidTooltip {
background: hsl(20, 1.5873015873%, 12.3529411765%);
border-color: rgba(255, 255, 255, 0.25);
}
.dark #graph-div .flowchartTitleText {
fill: #ccc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment