My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to create dark mode? (CSS)

Yashu Mittal's photo
Yashu Mittal
·May 30, 2019

Not asking about the implementation of JavaScript.

Just a heads up, if you are planning to create a dark mode for your application, you no longer need to use JavaScript, you can simply do it by @media query.

For example

@media (prefers-color-scheme: dark) {
  .day.dark-scheme   { background:  #333; color: white; }
  .night.dark-scheme { background: black; color:  #ddd; }
}

@media (prefers-color-scheme: light) {
  .day.light-scheme   { background: white; color:  #555; }
  .night.light-scheme { background:  #eee; color: black; }
}

I am want to know...

  • How to create dark mode with different dark colors?
  • How to select the colors and keep the contrast?
  • Is there any specific color palette for dark theme?

chrome_lUIwN3DUll.png