3 ms·
I agree. You can already do this using the space toggle technique: :root { --dark: ; } @media (prefers-color-scheme: dark) { --light: ; --dark:initial;
by miragecraft 3y ago
I agree.
You can already do this using the space toggle technique:
:root {
--dark: ;
}
@media (prefers-color-scheme: dark) {
--light: ;
--dark:initial;
}
.example {
color: var(--light, #000) var(--dark, #fff);
}
- zeroimpl 3y agoThat looks awful, but presumably if you are using sass instead of css you could define a light-dark macro already which does exactly that. I wonder if custom functions might ever make their way to css.
- Kerrick 3y agoAh yes, the CSS Space Toggle. The way this works internally is a seemingly-unintended but very useful aspect of the CSS specification.
- miragecraft 3y agoCorrection, the media query should have been: @media (prefers-color-scheme: dark) { :root { --light: ; --dark:initial; } } Missed the selector.