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?