Replies: 1 comment 1 reply
-
Creating css at runtime isn't optimal. The way svelte component styles are currently static allows us to externalize them into separate css files at buildtime, which has better runtime characteristics (file can be preloaded in parallel, cached, parsing and evaluation happens earlier etcpp). You can use css props in templates as shown in the sveltesociety recipe, add them to components automatically via css props is the platform solution for variables in css and for situations where they are not enough, svelte offers dynamic class and style attributes. What exactly are you missing that would justify implementing a complex feature that could also lead to worse runtime performance when not applied correctly? |
Beta Was this translation helpful? Give feedback.
-
Several years have passed since this topic was mentioned for the first time.
Recent issues:
sveltejs/svelte#758
sveltejs/svelte#3815
sveltejs/svelte#4354
sveltejs/svelte#4355
sveltejs/svelte#5034
...
This is partially implemented through the style tag, and should be implemented by default, as well as variables in html. They wanted to add it back in 2018. Vue has already added this.
The answer from the team: we are not interested in the implementation, we need to support IE, use css variables, it's a parsing nightmare, it doesn't work well with the IDE.
This resulted in sveltejs/rfcs#13, which is not exactly what is needed. Then appeared sveltejs/rfcs#51, but they decided to close it.
Now they suggest using css variables: https://sveltesociety.dev/recipes/svelte-language-fundamentals/passing-values-from-js-to-css
But this is just a workaround.
Is it really not necessary?
Beta Was this translation helpful? Give feedback.
All reactions