chr15m / minimal-stylesheet

CSS to get a web app up and running
https://chr15m.github.io/minimal-stylesheet
MIT License
60 stars 4 forks source link

User color scheme preferences (aka dark mode) #2

Open rafaelcastrocouto opened 3 years ago

rafaelcastrocouto commented 3 years ago

With a few lines you can add support for user color schemes:

minimal.css

@media (prefers-color-scheme: dark) {
  body, code, pre { background:  #333; color: white; }
  h1, h2, strong { color: white; }
}
minimal-inputs.css

@media (prefers-color-scheme: dark) {
  input, input[type="text"], input[type="password"], input[type="email"], input[type="tel"], select, textarea { 
    background:  #444; 
    color: white; 
  }
}

Maybe they could go to a file called dark.css, I don't know ... it's your choice.

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme

chr15m commented 3 years ago

Excellent, thank you!