diff --git a/apps/client/components/Navbar/index.vue b/apps/client/components/Navbar/index.vue index e9667a578..30743e9ec 100644 --- a/apps/client/components/Navbar/index.vue +++ b/apps/client/components/Navbar/index.vue @@ -9,14 +9,29 @@ const toggleDarkMode = () => { document.documentElement.classList.toggle('dark') } +const setDarkMode = (state = false) => { + if (state) { + document.documentElement.setAttribute("data-theme", "dark"); + document.documentElement.classList.add('dark') + } else { + document.documentElement.setAttribute("data-theme", "light"); + document.documentElement.classList.remove('dark') + } +} + +onMounted(() => { + const state = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches + setDarkMode(state) +}) +