119

Chrome 76 has added support for prefers-color-scheme media query (a.k.a. "dark mode").

But how can I test my webpage in both color schemes easily, without toggling the system dark mode on and off?

Here is the same question for Firefox, but I can't find similar settings in Chrome & Chrome DevTools.

xmcp
  • 3,347
  • 2
  • 23
  • 36

5 Answers5

196

Since Chrome version 79 you can toggle between prefers-color-scheme: dark and prefers-color-scheme: light from the Rendering panel

  1. Open Developer tools (otherwise the key combination below opens the print dialog)
  2. Open the Command Control: Ctrl+Shift+P or Command+Shift+P (Mac)
  3. Type "Show rendering"
  4. Set the Emulate CSS media feature prefers-color-scheme to the value you want to debug

drop down to select the mode

randers
  • 5,031
  • 5
  • 37
  • 64
AV Paul
  • 2,299
  • 1
  • 9
  • 11
21

How to emulate/activate prefers-color-scheme on Chrome (Desktop):

  1. Press F12 key (or Command+Shift+C on Mac)
  2. Click on the tree dots symbol (customize and control DevTools)
  3. Point your mouse on the more tools option, and then click in rendering option.
  4. the option Emulate CSS media feature prefers-color-scheme near the end it's your destination ! dumb visual guide to open color scheme

How to emulate/activate prefers-color-scheme on Chrome (Mobile):

  1. Click on the tree dots symbol.
  2. Click on Settings.
  3. Click on theme.
  4. Select you desired option !

Yay !!!

Edit June/22: If you want force dark colors to any website, you can browse chrome://flags/ and enable the flag: Auto Dark Mode for Web Contents (color inversion based)

Marlon da Veiga
  • 440
  • 5
  • 7
  • 1
    good, nice, but it only works while having the inspector open? – panchicore Sep 05 '22 at 08:26
  • I don't see how "Auto Dark Mode for Web Contents" is the same or as good as prefers-color-scheme media query. Auto dark mode automatically tries to render websites in dark (and it often looks terrible if there is no real dark mode) while the media query only works if the website has proper dark mode implemented. – LZ_ Jan 20 '23 at 23:23
4

Now you can find the settings in DevTools > Elements > Styles > Brush icon, in the upper right corner:

Brush icon

Destroy666
  • 892
  • 12
  • 19
2

This is a Chrome DevTools feature request that is tracked in crbug.com/977243 (star the bug or CC: yourself to be notified of progress). Meanwhile, it's already available in Safari's Web Inspector, see the heading Debugging Dark Mode in Apple's blog post.

As an alternative, if you want to automate the whole process, I have written a Puppeteer script that takes screenshots in dark and light mode, which can also be integrated in your CI testing.

DenverCoder9
  • 2,024
  • 11
  • 32
-1

On Chrome for Android, a flag was added in version 73 that adds a settings panel for dark theme, plus a checkbox for it in the browser menu. chrome://flags/#darken-websites-checkbox-in-themes-setting

Screenshot of flag "Darken websites checkbox in themes setting"

Screenshot of dark theme settings panel

Screenshot of dark theme checkbox in browser menu

Scott Martin
  • 1,260
  • 2
  • 17
  • 27