Skip to content

Commit 5629236

Browse files
author
vhtmui
committed
1
1 parent 1e00a93 commit 5629236

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/lib/components/my/ThemeToggle.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
}
2222
2323
onMount(() => {
24-
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches
25-
? 'dark'
26-
: 'light';
24+
const systemTheme =
25+
mode.current === 'light' || mode.current === 'dark'
26+
? mode.current
27+
: window.matchMedia('(prefers-color-scheme: dark)').matches
28+
? 'dark'
29+
: 'light';
2730
setTheme(systemTheme);
2831
});
2932
</script>

0 commit comments

Comments
 (0)