-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Milestone
Description
Describe the problem
In components that want to support use with CSS frameworks like Tailwind, it would be nice to allow users to pass in custom class names as props which are applied depending on an internal condition in the component:
Describe the proposed solution
MyComponent.svelte
:
export let dynamicClass = ''
let cond = false
<button class:{dynamicClass}={cond} on:click={() => cond = true}>click me</button>
Alternatives considered
This already works
<button class={cond ? dynamicClass : ''} on:click={() => cond = true}>click me</button>
but it looks cleaner here than in the real world where you might already have class attr in which case you need to manually combine classes before applying.
Importance
nice to have
ankarhem, juanmait, KevsRepos, StagnantIce, stLmpp and 13 morerochajulian