Support for prefers-color-scheme media query
See original GitHub issueApple introduced prefers-color-scheme
media query in Safari Technology Preview 68, which allows developers to apply different rules if user is using dark mode on Mac Mojave:
@media (prefers-color-scheme: light) { ... }
@media (prefers-color-scheme: dark) { ... }
https://trac.webkit.org/changeset/237156/webkit
Maybe it’s worth supporting this in Bootstrap?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:177
- Comments:50 (25 by maintainers)
Top Results From Across the Web
prefers-color-scheme - CSS: Cascading Style Sheets | MDN
The prefers-color-scheme CSS media feature is used to detect if a user has requested light or dark color themes.
Read more >prefers-color-scheme media query | Can I use... Support ...
Media query to detect if the user has set their system to use a light or dark color theme. Usage % of. all...
Read more >prefers-color-scheme: Hello darkness, my old friend - web.dev
The prefers-color-scheme media feature is used to detect if the user has requested the page to use a light or dark color theme....
Read more >@media (prefers-color-scheme) - CodePen
The prefers-color-scheme media query lets you create light and dark color schemes based on your system preferences. In browsers that support prefers-color- ...
Read more >Dark Mode - The prefers-color-scheme Website Tutorial
Learn how to enable dark mode in your OS in this article. There are two prefers-color-scheme values to choose from: light - the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like to start a little bit technical conversation here, as I recently implemented dark mode on websites I built with bootstrap.
Here are a few ideas:
Option 1
It is going to be tedious due to the ugly design of the
prefers-color-scheme
media query itself. Today’s bootstrap already provides light & dark theme on a few components, which means it would be difficult to modifying current implementation with mixins, and such change would doubling color related code as result (compression might help, but still very annoying). Just imagine the result as below:Option 2
We can drop
.*-dark
classes everywhere, and have light as default and dark in dark mode, which would cut the clutter, but would also greatly limit the possibility in website design.Option 3
We will never support prefers-color-scheme via mixin & in-stylesheet media query, instead bootstrap would officially support a build with different colors that’s optimized for dark mode, and users would use it like this:
The work to implement this option is minimum (pick a set of colors). It does have a catch that when dark mode is loaded, all css rules (including non-color related) are double loaded. However, this would also give designer the flexibility to choose between:
Option 4
Fully switch to css variables, which means drop IE 11 support. This might be a future solution but probably won’t happen anytime soon. https://caniuse.com/#feat=css-variables
Personally I would vote for option 3 today for two major reasons:
For the long term future (v6 I guess), I would vote for option 4.
What is ETA of dark mode? I’d like to have dark mode in b5 for new project.