Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect if Chrome's Devtools are using dark mode?

In Javascript from a PAGE and not from the devtools themselves is there currently a way to determine if Chrome's devtools are using dark mode instead of the "normal mode"?

I did find a bug report with a comment about this but it looks like that only relates to Chrome extensions.

like image 523
Alexis Tyler Avatar asked Jan 31 '17 15:01

Alexis Tyler


1 Answers

No, it's not available from a page.

It is only available for extensions in javascript via:

chrome.devtools.panels.themeName

The name of the color theme set in user's DevTools settings. Possible values: default (the default) and dark.

Since Chrome 59.

Source: https://developer.chrome.com/extensions/devtools_panels

So it's technically possible to write an chrome-extension that reads the value and then exposes that to the page via a class or javascript variable.
But requiring your visitors to install an extension for detecting dark mode just isn't practical.

like image 88
Bob Fanger Avatar answered Oct 18 '22 22:10

Bob Fanger