:root { @include light-theme; @media (prefers-color-scheme: dark) { @include dark-theme; } &[data-theme=light] { @include light-theme; } &[data-theme=dark] { @include dark-theme; } } @mixin light-theme { --background: hsl(0 0% 90%); --text: hsl(0 0% 10%); // ... } @mixin dark-theme { --background: hsl(0 0% 10%); --text: hsl(0 0% 90%); // ... }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter