Svelte and SvelteKit 5 · Template syntax

Toggle classes

Add a class conditionally with an object or array in the class attribute.

<div class={["card", { active: isActive, disabled }]}>...</div>

Official Svelte and SvelteKit 5 documentation

More template syntax commands

All template syntax commands · Svelte and SvelteKit 5 cheatsheet

Was this page helpful?