Example code for recognize system-theme
SRC: https://stackoverflow.com/questions/56393880/how-do-i-detect-dark-mode-using-javascript
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
console.log("Dark")
}
else {
console.log("Light")
}
// With event listener:
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
var theme = event.matches ? "dark" : "light";
});
Example code for recognize system-theme