DEV Community

loading...

Discussion on: DYK your website can get a dark mode toggled by your operating system?

Collapse
tomayac profile image
Thomas Steiner

The media query is now also supported in Chrome 76. To feature-detect if a browser supports it, you can use this snippet:

if (window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
  console.log('🎉 Dark mode is supported');
}