diff --git a/assets/ts/colorScheme.ts b/assets/ts/colorScheme.ts index 8cb8a20..978e98e 100644 --- a/assets/ts/colorScheme.ts +++ b/assets/ts/colorScheme.ts @@ -8,6 +8,10 @@ class StackColorScheme { constructor(toggleEl: HTMLElement) { this.bindMatchMedia(); this.currentScheme = this.getSavedScheme(); + if (window.matchMedia('(prefers-color-scheme: dark)').matches === true) + this.systemPreferScheme = 'dark' + else + this.systemPreferScheme = 'light'; this.dispatchEvent(document.documentElement.dataset.scheme as colorScheme);