I face a UI flick when using dark mode toggle in Astro when I move to new pages.
Website - https://vkleetcodesolutions.netlify.app/
Github - https://github.com/jsvigneshkanna/leetcode_solved_programs
#Dark mode toggle in Astro
7 messages · Page 1 of 1 (latest)
Try to use <script is:inline> in header to determine the current color mode
Currently your color mode is not determined until your darkModeToggler component is downloaded and executed. This will be too late.
This is how I did it: https://github.com/mrcaidev/mrcai.dev/blob/master/src/components/Head/BaseHead.astro#L39
Astro official example uses this approach too: https://codesandbox.io/s/github/withastro/astro/tree/latest/examples/docs?file=/src/components/HeadCommon.astro:710-1063
Great, will check
Hey there! I'm having the same issue, and the is:inline does fix it, however I'm wondering if there's a different way to achieve this without inlining the script? I was hoping to be able to import this script and also maybe bundle it with others, but that's not possible when using is:inline if I'm understanding right (or what I've tried at least).