This site runs best with JavaScript enabled.

prefers-color-scheme: Dark

Kevin Beck

September 20, 2019


I came accross new CSS media query today: prefers-color-scheme: dark.

It automatically detects if the user’s OS theme preferences is set to dark.

@media (prefers-color-scheme: dark) {
/* Do your thing... */
}

Support is small but so are the number of users setting theme preferences in their OS.

Reference

Source