Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Does Svelte facilitate dynamic CSS styling?

$
0
0

In Svelte, how should classes be changed on elements depending upon component state?

For instance, you may wish to apply a class to a button under certain conditions, as in the following example.

<button class="{{class}}">

Right now, this can be achieved by creating a computed property which would return class names, or empty strings, under certain conditions.

However, I am concerned over whether this might be polluting the computed properties namespace. For instance, if there were a status, it might be desired to both set a dynamic text, like statusMessage, and a class, like statusClass.

Is there a better way to do this, or are computed properties the way to go? Is any more explicit support for CSS planned for Svelte?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>