feat: enhance theme selection logic to respect OS preferences

This commit is contained in:
CNCKitchen
2026-03-25 17:00:22 +01:00
parent 558a2301db
commit b532c40a8e
2 changed files with 4 additions and 1 deletions
+4 -1
View File
@@ -9,7 +9,10 @@
// Apply saved theme before first paint to avoid flash
(function() {
const t = localStorage.getItem('stlt-theme');
if (t !== 'dark') document.documentElement.setAttribute('data-theme', 'light');
// If user never picked a theme, respect their OS preference
const prefersDark = t ? t === 'dark'
: window.matchMedia('(prefers-color-scheme: dark)').matches;
if (!prefersDark) document.documentElement.setAttribute('data-theme', 'light');
})();
// Apply saved language before first paint to avoid flash
(function() {