Quick Dark Mode Toggles

Chris Coyier Chris Coyier on

I’ve moved off of Arc browser, but it had a browser-level feature of being able to toggle beween light and dark mode that I liked. I still have some muscle memory for that, so in the time I’m spending back on other Chrome-based browsers, I was looking for another browser-level toggle for it.

Chrome

Chrome can do it, but it’s a little buried in DevTools. The main setting is under the “Rendering” tab (which I always remember how to get to be going under the main Console tab then pressing ESC, then choosing Rendering in the three-dot menu). In there, you’ll see an option for Emulate CSS media feature prefers-color-scheme where you can select light or dark.

Screenshot of Chrome DevTools showing the 'Rendering' tab with options for emulating CSS media feature prefers-color-scheme.

Alternatively, it’s a bit quicker to use the Command Palette (Command-Shift-P) and starting typing emulate and you’ll see a quick option to toggle to the value you want.

Screenshot of Chrome DevTools Command Palette with options for emulating CSS prefers-color-scheme.

Or, use the little paintbrush icon under the Elements tab then in the Styles section.

Screenshot of a browser's DevTools showing the Styles panel, with options to toggle between light and dark color schemes.

The Non-Standard Chrome Thing

See in the first screenshot there is a setting called Enable automatic dark mode as well. I have made this mistake recently of thinking this was how you flip on dark mode testing, and it was pointed out to me, hence this blog post. That feature is some Chrome-specific thing which takes a page which may have been designed as light-mode-first (or only) and forces a dark mode on it whether it was designed to or not.

Screenshot of a coding environment showing the Chrome DevTools interface with the Console and Rendering tabs open, highlighting options for enabling automatic dark mode and simulating CSS media features.
This blog post in the WordPress editor with forced dark mode. This page doesn’t support a dark mode normally.

The Enabled automatic dark mode feature isn’t particularly relevant. I think it’s some Chrome team idea that hasn’t gone anywhere yet. It’s not something you’d really need to test with/for in my opinion.

Firefox

Firefox has some mutually exclusive buttons in DevTools under the Inspector panel. The little sun icon is simulating preferring light mode and the moon(ish) icon is preferring light mode. Or they can both be off defaulting to the system.

Screenshot of Chrome DevTools, showing the Inspector panel with options for toggling dark color scheme simulation for web pages.

Safari

In Safari DevTools under the Elements panel there is an icon to control the color modes as well as some other accessibility media preference simulators.

A screenshot of browser developer tools displaying the appearance settings, specifically the color scheme set to dark, under the Elements tab.

OS

Other than the non-standard Chrome thing, all this is doing is pretending as if the user has set one of the modes specifically at their OS level.

A user interface displaying color mode options for appearance settings, including Light, Dark, and Auto modes.
The macOS version of setting Dark Mode.

Personally, I find it a little cumbersome to need DevTools or go into System Settings to test dark/light mode on sites. It was nice in Arc to have a simple command to do it, but as I write, color modes aren’t really a browser-level settings for the most part (let alone site-specific settings).

So I was happy to find Nightfall, a little macOS menu bar utility for swapping out color modes.

There is something extra nice about doing the toggling at the system level as it feels like the “real” way to do it.

Learn Chrome DevTools Deeply

Frontend Masters logo

We have a great Introduction to DevTools course from Jon Kuperman, so popular that it's now in its 3rd edition! You'll learn how to profile your web applications, step through code with a debugger, and audit page performance to remove jank.

7-Day Free Trial

Leave a Reply

Your email address will not be published. Required fields are marked *

$839,000

Frontend Masters donates to open source projects through thanks.dev and Open Collective, as well as donates to non-profits like The Last Mile, Annie Canons, and Vets Who Code.