Use multiple classes with one condition
pnpm i -D svelte-multicssclasses
OR
npm i -D svelte-multicssclasses
OR
yarn i -D svelte-multicssclasses
// vite.config.js
import { sveltekit } from '@sveltejs/kit/vite'
import { multicssclass } from 'svelte-multicssclasses'
const config = {
plugins: [multicssclass(), sveltekit()] //ADD HERE
}
export default config
const sampleBoolean = true
Use . to combine multiple classes
<div class:sample-class-1.sample-class-2.sample-class-3="{sampleBoolean}">Example</div>
WILL BE COMPILED TO
<div
class:sample-class-1="{sampleBoolean}"
class:sample-class-2="{sampleBoolean}"
class:sample-class-3="{sampleBoolean}"
>
Example
</div>
WILL BE COMPILED TO
<div class="sample-class-1 sample-class-2 sample-class-3">Example</div>
const sampleBoolean = true
Use ! infront of class to negate condition for that specific class
<div class:!sample-class-1.!sample-class-2.sample-class-3="{sampleBoolean}">Example</div>
WILL BE COMPILED TO
<div
class:sample-class-1="{!sampleBoolean}"
class:sample-class-2="{!sampleBoolean}"
class:sample-class-3="{sampleBoolean}"
>
Example
</div>
WILL BE COMPILED TO
<div class="sample-class-3">Example</div>