Replies: 5 comments 1 reply
-
Hi there! The light theme is the "default" theme. It's scoped to One way to prevent flashing is to do like we do in the docs: shoelace/docs/_includes/default.njk Lines 41 to 48 in c88b38f Importantly, that script is located in the Another way is to conditionally load the light/dark stylesheets based on prefers-color-scheme, e.g. <link rel="stylesheet" href="light.css" media="(prefers-color-scheme: light)" />
<link rel="stylesheet" href="dark.css" media="(prefers-color-scheme: dark)" /> I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
@claviska Maybe you could add |
Beta Was this translation helpful? Give feedback.
-
Apologies. We both posted at the same time so I did not see your previous response. I am looking for a way to maintain your requirements while fixing the FOUC. Give me a minute and I will post a testcase for you to reproduce the problem on your end. |
Beta Was this translation helpful? Give feedback.
-
@claviska Please open this up on your end. It's easier to see if you host the files on a remote server, and enable "Slow 3G" throttling, but you can also see the problem if you just open the files locally and keep on hitting F5 or CTRL+F5 quickly. Let me know if you able to reproduce the problem on your end. |
Beta Was this translation helpful? Give feedback.
-
I apologize. I see now that if I replace the I guess this is a bundler problem, as they are converting |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I read #1842 so I understand that you included
:root
as a convenience on the light theme. The problem is that if a user loads the following HTML:Then initially the light theme gets applied (flash of white) and then the dark theme gets applied (flash of black). If you were to omit
:root
and let users explicitly choose the theme they want then I believe it would be possible to avoid this.To Reproduce
The problem can be reproduced with this, but throttling makes it easier to see.
Browser / OS
Beta Was this translation helpful? Give feedback.
All reactions