Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I emulate prefers-color-scheme media query in Chrome?

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.

like image 223
xmcp Avatar asked Aug 22 '19 10:08

xmcp


People also ask

What is prefers-color-scheme CSS media?

The prefers-color-scheme CSS media feature indicates if the user prefers light or dark color scheme. Under the Emulate CSS media feature prefers-color-scheme, select one of the following from the dropdown list: refresh Reload the page. For example: The print media query controls how your page looks when printed.

How do I use the emulate CSS media feature?

Under the Emulate CSS media feature prefers-color-scheme, select one of the following from the dropdown list: refresh Reload the page. For example: The print media query controls how your page looks when printed. Open the Rendering tab and under Emulate CSS media type select print.

What is the print media query for?

The print media query controls how your page looks when printed. Open the Rendering tab and under Emulate CSS media type select print. From here, you can view and change your CSS, like any other web page.

What is the prefers-reduced-motion CSS media feature?

The prefers-reduced-motion CSS media feature indicates if the user has requested to minimize the amount of motion on a page. Open the Rendering tab on this demo and try scrolling to see various animations. Under the Emulate CSS media feature prefers-reduced-motion, select prefers-reduced-motion:reduce.


1 Answers

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

like image 53
AV Paul Avatar answered Sep 25 '22 15:09

AV Paul