-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with custom styles in dark mode? #4687
Comments
I think the problem is with .links being applied to the So that local.css should define
|
Using the media query won't work with forced dark-mode via the toggle in sidebar (that comes from fixup.js). See w3c@031abec#diff-cefc979f9d55dee149c3b7b5b410cf2d5db0c13d16bf3b379780a1a7ccaab5e2R24-R30 for example. So, the best strategy would be to use one of the variables from https://www.w3.org/StyleSheets/TR/2021/dark.css (and https://www.w3.org/StyleSheets/TR/2021/base.css) to support consistent dark mode styles (including custom styles). Even with ReSpec's dark mode support, I avoided media query as much as possible and used variables from W3C stylesheet. |
Opinion: I'm not in favor of existence of toggles. The |
Alternative would be to watch whether dark.css applies using JS (mutation observer on that link element), and then add a class to |
I like/use the toggle myself... because I don't like the specs on the dark background, even when the rest of the OS is in dark mode... so I get it. |
So maybe fixup.js should add a |
I see. Thanks. Filed w3c/tr-design#349 |
Someday in future we can use style queries to simplify that. Someday... |
fixup.js now adds a |
I actually cannot find a way to make it work in case JS is disabled, while avoiding dark style duplication. With duplication, I'm hoping something like following: .foo {
/** light mode styles */
}
/** prefers dark mode, and not forced light mode */
@media (prefers-color-scheme: dark) {
body:not(.lightmode) .foo {
/** dark mode styles */
}
}
/** forced JS darkmode */
body.darkmode .foo {
/** dark mode styles again */
} @tabatkins any guidance 🙏🏽? |
The better route, rather than add a class to the body, is to add (or manipulate an existing) |
(And ideally, generate the spec with |
Hmmm... so, we do generate I think we should:
That would solve for this. |
@tabatkins Not sure I followed right, but shouldn't following result in forced dark mode? (Chrome 124 on Mac OS 14) |
Sigh, I thought it did, but I guess I just tested its effect on the used color scheme, not the MQ. It looks like it does indeed not affect the MQ. I'm gonna raise this in the CSSWG. |
Tracked in w3c/csswg-drafts#10249 |
Any progress on this issue? I assume we are able to solve this in a way that does not depend on changes to CSS specs? |
Description of problem
URL to affected spec or repo:
What happened (e.g., it crashed)?:
If the OS is in dark mode, the colour is correct.
Expected behavior (e.g., it shouldn't crash):
Colours should follow the
@media (prefers-color-scheme: dark)
media query.The text was updated successfully, but these errors were encountered: