import '../app.css';
, Dark Mode, and const ssr = false;
- background-color
blink
#6564
-
In CSR Mode ( <!-- src/routes/+layout.svelte -->
<script>
import '../app.css';
</script> /* src/app.css */
@media (prefers-color-scheme: dark) {
:root {
--color: white;
--background-color: #333;
}
}
@media (prefers-color-scheme: light) {
:root {
--color: #333;
--background-color: white;
}
}
html, body {
color: var(--color);
background-color: var(--background-color);
} Causes a blinking white background. Even though dark mode is enabled on the system. QUEST: I currently place the style in <link rel="stylesheet" href="%sveltekit.assets%/app.css">. ...but even the Hello World example uses BETTER QUESTION: Maybe loading The most important thing is consistent DX. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
If anyone thinks this is a joke or something unimportant: I'm writing in deadly seriousness, this is something worth looking into, and securing. |
Beta Was this translation helpful? Give feedback.
-
To avoid that problem I set the theme before the page loads in the |
Beta Was this translation helpful? Give feedback.
-
You pretty much can not extract styles without server rendering the app so some sort of prerendering is needed.
You can´t load a js module before rendering since it is deferred by default. So you either have to prerender or link the styles in app.html. |
Beta Was this translation helpful? Give feedback.
-
Can you evaluate this proposal, on this issue from this discussion? Global Layout on server side, Page on client side. Global layout as shell |
Beta Was this translation helpful? Give feedback.
-
Mr. @Conduitry rejected my proposal #6636 I'm also writing here for someone to see: Of course that this behavior IS NOT expected. I described it in the Story! We already had a situation where you thought the user was smarter than he actually could be - sveltejs/svelte#5797 (comment)
PS I apologize for the emotional tone of this post. |
Beta Was this translation helpful? Give feedback.
-
The simplest solution to the problem (although I haven't tested it much): <!-- src/routes/+layout.svelte -->
<script>
import '../app.css';
import { browser } from "$app/environment";
</script>
{#if browser}
<slot />
{/if} And It hadn't occurred to me before.... :D |
Beta Was this translation helpful? Give feedback.
The simplest solution to the problem (although I haven't tested it much):
And
src/routes/+layout.svelte
withexport const ssr = true;
(as it is by default).It hadn't occurred to me before.... :D