Switch Dark/Light automatically based on user browser preference #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses the
prefers-color-schemeCSS media query to automatically switch back and forth between dark + light with the same theme following this approach. I combined the Discord Light & Dark to demo.It mostly works, and should be backwards compatible with the rest of the themes.
Unfortunately, it does not work with the SASS mixins like
adjust-coloror the customrecolorsince those need colors at compile time, not compatible with the CSS vars. For now I've just kept those as the base variable.I didn't see a clear way to fix those, and unfortunately there are quite a few. The most straightforward would be to define additional variables, but that's not great. Will look again when I have time. Or maybe there is another way to do it with SASS I didn't see.
Same theme; switched between Dark/Light preference: