Skip to content

Commit

Permalink
Detect browser theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed Apr 16, 2024
1 parent 0268b33 commit f0b2ac7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions meshmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ window.onload = function() {
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-theme', 'dark');
toggleSwitch.checked = true;
}

toggleSwitch.addEventListener('change', switchTheme, false);
Expand Down

0 comments on commit f0b2ac7

Please sign in to comment.