1const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
1const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
2
3console.log(isDarkMode) // Result: True or False
4
1if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
2 // dark mode
3}
4