question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support website's native dark mode

See original GitHub issue

Firefox 67 introduced the new prefers-color-scheme CSS media feature. (It’s not currently available for any other browsers that support browser/WebExtensions.)

With that websites can detect a dark system mode and adjust their design.

It would obviously be great, if you could integrate that, somehow. And there are many possibilities.


That said, I’ve already tried that (to force a particular design) and it is really not a nice thing to implement. At least forcing the black design works, as this is how websites likely implement it, but anything else is likely not really possible…

So this is rather a proof-of-concept (although it works quite fine if you just want to force the websites to use their native black design.).

Test the add-on here!

Source code: https://github.com/rugk/website-dark-mode-switcher/

What is easy is:

  • get the system state and apply the add-on based on it. (just a .matchMedia query and you know it)

What is hard is:

  • forcing websites to use a particular design

You may also just disable this add-on on sites, where you detect it used. It opens many possibilities/ideas…

Edit: Due to new Firefox APIs the v2 of the linked extension is much more powerful and now can easily and reliably force the dark or light mode on websites.


Test sites are linked in the add-on, but here again:

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:82
  • Comments:37 (12 by maintainers)

github_iconTop GitHub Comments

17reactions
haselwartercommented, Feb 20, 2022

This issue has been open for almost 3 years, and by now prefers-color-scheme is supported by a good part of the web. Dark mode detection doesn’t have to do magic, but making sure it works on websites that use meta tags correctly would be a good first step. It’d be a real improvement towards integrating Dark Reader with the contemporary ecosystem.

9reactions
flying-sheepcommented, Mar 25, 2022

Respect the user’s choice to explicitly choose a light theme for GitHub only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome, Firefox, and Safari now support dark mode for websites
Websites can now add support for native dark mode for Windows, macOS, iOS, and Android by using the prefers-color-scheme CSS media query.
Read more >
Blackout: How to Enable Dark Mode on Your Browser | PCMag
Here's how to enable dark mode in Chrome, Firefox, Safari, and Edge. ... see which websites will use a dark theme alongside your...
Read more >
How to force Google Chrome to show any website in dark mode
Click on the Dark option. Similar to Windows, all apps with a native dark mode will switch over. How to enable dark mode...
Read more >
Welcome to the Dark Side - Our Website Now Supports Dark ...
Our website now supports your operating systems native dark mode - depending on the settings of your device, this website will be either ......
Read more >
Dark Mode List - Most Popular Dark Mode Apps that You ...
A list of 300 Popular iOS Apps, Mac Apps and Websites that support Dark Mode like Instagram, Facebook, Reddit, macOS, Slack, Twitter, YouTube...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found