dark mode no javascript code example
Example 1: javascript detect dark mode
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Example 2: css dark mode
@media (prefers-color-scheme: dark) {
body {
background-color: black;
color: white;
}
}