How to create dark mode? (CSS)
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?