diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index fc61a3179..3651a92db 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -90,19 +90,29 @@ $: { if (browser) { const isCloudClass = isCloud ? 'is-cloud' : ''; + if ($app.theme === 'auto') { const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)'); if (darkThemeMq.matches) { - document.body.setAttribute('class', `theme-dark ${isCloudClass}`); + document.body.setAttribute('class', `theme-dark ${isCloudClass} no-transition`); $app.themeInUse = 'dark'; } else { - document.body.setAttribute('class', `theme-light ${isCloudClass}`); + document.body.setAttribute( + 'class', + `theme-light ${isCloudClass} no-transition` + ); $app.themeInUse = 'light'; } } else { - document.body.setAttribute('class', `theme-${$app.theme} ${isCloudClass}`); + document.body.setAttribute( + 'class', + `theme-${$app.theme} ${isCloudClass} no-transition` + ); $app.themeInUse = $app.theme; } + requestAnimationFrame(() => { + document.body.classList.remove('no-transition'); + }); } } @@ -123,6 +133,12 @@