brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Test dark mode in Chrome DevTools without changing your OS theme

Devtools
~/tips/tip-devtools-emulate-prefers-color-scheme

@media (prefers-color-scheme: dark) {

Switches the page between light and dark styling from inside DevTools.

If a site follows prefers-color-scheme, you don’t need to flip your whole system to dark mode to check it. DevTools can pretend for one tab.

Open the Rendering tab (three-dot menu, More tools, Rendering). Under Emulate CSS media feature prefers-color-scheme pick light or dark, then reload the page if it doesn’t update on its own.

@media (prefers-color-scheme: dark) {
  body { background: #111; color: #eee; }
}

With the dark option selected, that block applies in the tab even though your system is set to light. The same tab emulates other media features too: print media type, forced-colors, prefers-contrast, prefers-reduced-motion, prefers-reduced-transparency and color-gamut.

The emulation lives in DevTools. Close DevTools or the tab and it’s gone, and it only affects CSS media queries. A script that reads the theme from somewhere else, like a saved setting in local storage, won’t change.

The print option is worth a try before you waste paper. Select print as the media type and the page shows your @media print rules on screen, ready to inspect in the Elements panel.

Further reading: Emulate CSS media features

More Devtools tips Clear site data for one site from Chrome DevTools user.id === 42 $x(path [, startNode]) queryObjects(Promise) inspect(document.querySelector('footer')) All Devtools tips (22) All topics

Link