diff --git a/app/ThemeScript.tsx b/app/ThemeScript.tsx new file mode 100644 index 000000000..2f022f988 --- /dev/null +++ b/app/ThemeScript.tsx @@ -0,0 +1,16 @@ +// We inject the theme script to prevent flash of white when the page loads +const ThemeScript = () => { + const themeScript = ` + (function() { + const storedTheme = localStorage.getItem('theme') + if (storedTheme === '"light"') return; + if (storedTheme === '"dark"' || window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.documentElement.classList.add('dark') + } + })() + `; + + return