You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some CSS styles not applied with non-zero inlineStyleThreshold since v2.21.3 #13878
changed the title [-]CSS inlining regression after PR #13723: shared SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression after PR #13723: SCSS files not inlined when inlineStyleThreshold > 0[/+]on Jun 11, 2025
changed the title [-]CSS inlining regression after PR #13723: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/+]on Jun 11, 2025
changed the title [-]CSS inlining regression sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression after sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/+]on Jun 11, 2025
changed the title [-]CSS inlining regression after sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]Some CSS styles not applied with non-zero inlineStyleThreshold since v2.21.3[/+]on Jun 11, 2025
I can confirm this bug as I thought I was hallucinating 😅
It is not styling my Button component (which is normally imported, not dynamically) with the inlineStyleThreshold config option to 4096. It used to work a week ago and since this version, it doesn't build the style of my component when building.
At the moment to keep this working I had to lower the threshold to 1024.
elliott-with-the-longest-name-on-github commented on Jun 11, 2025
I can confirm this bug as I thought I was hallucinating 😅 It is not styling my Button component (which is normally imported, not dynamically) with the inlineStyleThreshold config option to 4096. It used to work a week ago and since this version, it doesn't build the style of my component when building.
At the moment to keep this working I had to lower the threshold to 1024.
Are you able to create a minimal reproduction? Or if you're unable to, could you share the styles? How were the styles added? In thee Svelte style block? Or imported as a CSS file in the Svelte script tag? Or how the component was imported into the page/layout?
I'm finding this difficult to reproduce at the moment. A few things I've tried:
Inlining CSS for the page component.
Importing a component and inlining that CSS.
Importing a component which imports another component and inlining that CSS.
Let me know if there are other cases I should try. I wonder if CSS syntax plays a part here.
What is weird is that this exact code that I haven't changed works and build styles correctly on 2.21.2 but not on 2.21.3 or 2.21.4
Thank you! I've tried to reproduce this by adding sveltePreprocss, sass, and the scss + svelte code but I'm not sure what I'm suppose to expect. Can you share a screenshot of what the button looks like working/broken? Also, I'm missing some of the global styles the scss references like --color-dark, so I don't know if my comparison will be accurate. However, I can see the styles inlined in the <head>. I just don't know if the issue is that the styles are not inlined or if the styles are inlined but not applying correctly?
It simply doesn't compile or applies the styles for this component for some reason. While running dev, it's all good but when building, it just renders the button as the default style 🤔
@eltigerchino I tried to replicate it on a smaller setup by just keeping a <Button /> in a <main> within a +page.svelte and it builds fine for some reason, with the same Svelte config. This is quite weird! I'll keep investigating but I suspect that a bigger site with many more components can cause some sort of a threshold with the inlineStyle setting?
I’m trying to reproduce the issue with the minimal setup, but I haven’t been able to reproduce it yet.
I’m using SCSS for styling and not using dynamic imports.
@tkhs0813 @eltigerchino I gave another go and it seems that only one component is affected in my case, which is weird.
I think I found the issue, or at least a case where it happens: using this component in that route routes/product/[product]/+page.sveltewithout having a root page for /product seems to be the culprit. I literally have nothing else than <Button href="/page" label="Test" /> in the page and the styles are not being built.
Is this of any help? Or does that make any sense? 😅
The only way to make this work with inlineStyleThreshold is to lower the value to 2048.
Another case where all the styles would build including my nested <Button /> component: when I do NOT add the stylesheet for my routes/product/[product]/+page.svelte, or have an empty stylesheet:
@eltigerchino
For your reference:
We still haven’t been able to reproduce the issue with a minimal setup, but we were able to resolve the missing styles problem in our application by using Cursor. #14007
However, we're not sure if this fix is actually appropriate.
Sorry, this kinda got lost in the backlog for me personally as I've had to prioritise some non-SvelteKit work last month. I'll try to see if I can squeeze some time in for this this week or next (most likely).
@tkhs0813@eltigerchino I gave another go and it seems that only one component is affected in my case, which is weird.
I think I found the issue, or at least a case where it happens: using this component in that route routes/product/[product]/+page.sveltewithout having a root page for /product seems to be the culprit. I literally have nothing else than <Button href="/page" label="Test" /> in the page and the styles are not being built.
Is this of any help? Or does that make any sense? 😅
The only way to make this work with inlineStyleThreshold is to lower the value to 2048.
If both of you really can't create a minimal reproduction, if you're open to it, you could temporarily share the private repository with me and I can give it a try too.
I have created a minimal reproduction for my experience of this issue:
⚠️ The bug only happens when running pnpm run build && pnpm run preview (with inlineStyleThreshold > 0) and NOT during pnpm run dev!
<scriptlang="ts">
importNuggetfrom"./Nugget.svelte"let show =$state(false)
</script>
<section>
<buttononclick={() => (show=!show)}>Toggle Show</button>
{#ifshow}
<Nuggettext="abc"id={null} />
{/if}
</section>
<!-- 1. With this `<style>` "active", then Nugget's `<style>` IS NOT applied ❌ -->
<style>
section {display: flex;flex-direction: column;align-items: center; }
</style>
<!-- 2. With an empty `<style>` or no `<style>` at all, then Nugget's `<style>` IS applied ✅ --><!-- <style></style> --><!-- 3. This causes a weird "Server stylesheet source not found for client stylesheet" error (maybe unrelated) --><!-- <style> /* */</style> -->
Sorry this was delayed for so long. The recent reproduction is incredibly helpful. I've started investigating and should be able to come up with something by next week as I will be maintaining SvelteKit full time thanks to the Svelte Open Collective (however, I'm currently on leave this week).
Some notes so far:
An SSR-ed page with no styles fetches the css of the conditionally rendered components only when it's first rendered
If the SSR-ed page has styles, it is inlined. However, those styles exclude the conditionally rendered component styles because the component is not rendered during SSR. It is also not fetched later when it's first rendered because the styles for every component in the page is being grouped together on the client-side. This causes client to think that the styles have already been loaded when we inline the server styles.
Reacted by Félix, Tim Guggenmos, ryo takahashi and vultix
Activity
[-]CSS inlining regression after PR #13723: shared SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression after PR #13723: SCSS files not inlined when inlineStyleThreshold > 0[/+][-]CSS inlining regression after PR #13723: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/+][-]CSS inlining regression sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]CSS inlining regression after sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/+][-]CSS inlining regression after sveltekit@2.21.3: SCSS files not inlined when inlineStyleThreshold > 0[/-][+]Some CSS styles not applied with non-zero inlineStyleThreshold since v2.21.3[/+]flayks commentedon Jun 11, 2025
I can confirm this bug as I thought I was hallucinating 😅
It is not styling my Button component (which is normally imported, not dynamically) with the
inlineStyleThresholdconfig option to 4096. It used to work a week ago and since this version, it doesn't build the style of my component when building.At the moment to keep this working I had to lower the threshold to 1024.
elliott-with-the-longest-name-on-github commentedon Jun 11, 2025
@eltigerchino is this related to that dynamic component styling PR?
teemingc commentedon Jun 12, 2025
Probably. I'll have a look and try to find a reproduction.
teemingc commentedon Jun 12, 2025
Are you able to create a minimal reproduction? Or if you're unable to, could you share the styles? How were the styles added? In thee Svelte style block? Or imported as a CSS file in the Svelte script tag? Or how the component was imported into the page/layout?
I'm finding this difficult to reproduce at the moment. A few things I've tried:
Let me know if there are other cases I should try. I wonder if CSS syntax plays a part here.
flayks commentedon Jun 12, 2025
@eltigerchino Here is my component Button.svelte:
And styles:
Then imported that way, as simply as it can be:
Using this config:
What is weird is that this exact code that I haven't changed works and build styles correctly on 2.21.2 but not on 2.21.3 or 2.21.4
teemingc commentedon Jun 12, 2025
Thank you! I've tried to reproduce this by adding sveltePreprocss, sass, and the scss + svelte code but I'm not sure what I'm suppose to expect. Can you share a screenshot of what the button looks like working/broken? Also, I'm missing some of the global styles the scss references like
--color-dark, so I don't know if my comparison will be accurate. However, I can see the styles inlined in the<head>. I just don't know if the issue is that the styles are not inlined or if the styles are inlined but not applying correctly?flayks commentedon Jun 12, 2025
It simply doesn't compile or applies the styles for this component for some reason. While running dev, it's all good but when building, it just renders the button as the default style 🤔
1 remaining item
flayks commentedon Jun 13, 2025
@eltigerchino I tried to replicate it on a smaller setup by just keeping a
<Button />in a<main>within a+page.svelteand it builds fine for some reason, with the same Svelte config. This is quite weird! I'll keep investigating but I suspect that a bigger site with many more components can cause some sort of a threshold with the inlineStyle setting?tkhs0813 commentedon Jun 16, 2025
I’m trying to reproduce the issue with the minimal setup, but I haven’t been able to reproduce it yet.
I’m using SCSS for styling and not using dynamic imports.
flayks commentedon Jul 10, 2025
@tkhs0813 @eltigerchino I gave another go and it seems that only one component is affected in my case, which is weird.
I think I found the issue, or at least a case where it happens: using this component in that route
routes/product/[product]/+page.sveltewithout having a root page for/productseems to be the culprit. I literally have nothing else than<Button href="/page" label="Test" />in the page and the styles are not being built.Is this of any help? Or does that make any sense? 😅
The only way to make this work with
inlineStyleThresholdis to lower the value to 2048.The component in question:
Could it be because of the
<svelte:element>?EDIT: having refactored the component to use a
content()snippet and conditions based on the tag, it's not that!flayks commentedon Jul 10, 2025
Another case where all the styles would build including my nested
<Button />component: when I do NOT add the stylesheet for myroutes/product/[product]/+page.svelte, or have an empty stylesheet:I feel there is a bug somewhere related to stylesheets with dynamic routes.
tkhs0813 commentedon Jul 17, 2025
@eltigerchino
For your reference:
We still haven’t been able to reproduce the issue with a minimal setup, but we were able to resolve the missing styles problem in our application by using Cursor.
#14007
However, we're not sure if this fix is actually appropriate.
inlineStyleThreshold! #14110 as a duplicate of this issueteemingc commentedon Sep 2, 2025
Sorry, this kinda got lost in the backlog for me personally as I've had to prioritise some non-SvelteKit work last month. I'll try to see if I can squeeze some time in for this this week or next (most likely).
teemingc commentedon Sep 11, 2025
I can't reproduce this in https://stackblitz.com/github/eltigerchino/13878
If both of you really can't create a minimal reproduction, if you're open to it, you could temporarily share the private repository with me and I can give it a try too.
timephy commentedon Dec 12, 2025
I have created a minimal reproduction for my experience of this issue:
pnpm run build && pnpm run preview(withinlineStyleThreshold > 0) and NOT duringpnpm run dev!The entire repo is available here: https://github.com/timephy/sveltekit-inlineStyleThreshold-bug
I have been struggling with this for the duration of this open issue. I have set
inlineStyleThreshold: 0to fix this in the mean time.I hope this helps you @teemingc to debug this problem, I would appreciate a fix a lot!
I'll leave some things I observed here:
{#if}block is mandatory for this bug to occur<style>block is required in the component that has the{#if}block@apply, it also happens with "native css"Also:
{#if}blocks, but maybe also with{#each ...}block, etc...I have a large code base where this issue appears in multiple places... I'd be happy to test a fix against it! 👍🏽
timephy commentedon Jan 7, 2026
teemingc commentedon Jan 7, 2026
Sorry this was delayed for so long. The recent reproduction is incredibly helpful. I've started investigating and should be able to come up with something by next week as I will be maintaining SvelteKit full time thanks to the Svelte Open Collective (however, I'm currently on leave this week).
Some notes so far:
fix: use client CSS for inlineStyleThreshold to include conditionally…
timephy commentedon Jan 28, 2026
Thank you guys!!