Skip to content

Instantly share code, notes, and snippets.

@Alhadis
Last active April 27, 2022 11:50
Show Gist options
  • Save Alhadis/9feaefb09899352e580a5bb8f96e436d to your computer and use it in GitHub Desktop.
Save Alhadis/9feaefb09899352e580a5bb8f96e436d to your computer and use it in GitHub Desktop.
SVG Dark Mode Test
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" width="512" height="512" viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve"
><style type="text/css">
text{
font-size: 16px;
font-family: sans-serif;
font-weight: bold;
display: none;
}
#unsupported{
display: initial;
}
@media (prefers-color-scheme: dark){
text { fill: #fff; }
svg { background: #000; }
#unsupported { display: none; }
#dark { display: initial; }
}
@media (prefers-color-scheme: light) {
text { fill: #000; }
svg { background: #fff; }
#unsupported { display: none; }
#light { display: initial; }
}
</style>
<text id="unsupported" y="20">Unsupported</text>
<text id="light" y="20">Light mode</text>
<text id="dark" y="20">Dark mode</text>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment