Firefox: How to test prefers-color-scheme?

后端 未结 3 1872
无人共我
无人共我 2021-02-03 19:02

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

相关标签:
3条回答
  • 2021-02-03 19:05

    Another way to do this is to go to about:config, and set the devtools.inspector.color-scheme-simulation.enabled property to true.

    This adds a button to the devtools inspector tab which allows you to quickly switch between emulating light mode and dark mode on the current page.

    Eventually this feature will no longer be hidden behind a flag. You can track its progress on Bugzilla. As of November 2020, there is also a new bug for getting this flag enabled by default.

    0 讨论(0)
  • 2021-02-03 19:12

    You can update the style used by Firefox by going to about:config and adding a new property ui.systemUsesDarkTheme of integer type with value 1.

    It doesn't automatically update the value on active pages in the same way that it does when you're updating OS settings in Windows or Mac, but if you refresh the page after updating it will pick up.

    You can confirm the browser setting is correct by viewing the example on mdn

    Edit: On firefox 71 the update is applied to active pages without refresh

    0 讨论(0)
  • 2021-02-03 19:23

    Just for the sake of completeness: If everything fails, there is a Firefox add-on called “Dark Website Forcer” (also on GitHub).
    It changes the style by reading the CSS of the website and re-applying the parts for the dark version again, if you want to have a dark one. As such, it also can only force a dark website, not the light one. The Readme has a detailed explanation why.

    Disclosure: I'm the author of this add-on.

    0 讨论(0)
提交回复
热议问题