In Firefox 67, one can use media queries to detect user preference on light or dark theme.
In my version of Firefox (under Ubuntu), it seems that my preference is light theme. That is, the following CSS gives a blue background:
@media (prefers-color-scheme: light) { :root {} body { background-color: blue; } }
How can I change my Firefox preferences so that prefers-color-scheme: dark
evaluates to true?
I found an add-on that seems to do the trick, but I must be doing something wrong with my own CSS, as it does not work on my page. Dark Website forcer
Web browser support as of March 2019 For current browser support, check out https://caniuse.com/#search=prefers-color-scheme.
You can also trigger toggling the dark mode with the hot key <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>B</kbd> (customizable in the Firefox add-on settings). This extension only works with Firefox v95 or higher. You can use a toolbar button to toggle whether it should force a dark mode or not.
As dark mode is reported through a media query, you can easily check if the current browser supports dark mode by checking if the media query prefers-color-scheme matches at all.
Good news -- from Firefox 87 this is now enabled by default, without the need to set a configuration flag! You can find it in the inspector tab:
In some older versions of Firefox, this feature existed behind a flag. To test on one of those versions, you can thus enable this by going to about:config
, and setting the devtools.inspector.color-scheme-simulation.enabled
property to true
. Once that's done, you'll find the controls for it in the same place as in the modern devtools, but as a single paintbrush icon rather than today's sun/moon toggle buttons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With