Svelte · Junior · Question 26 of 76
How can you pass several classes conditionally in Svelte 5?
<div class={["card", { active: isActive, disabled }]}></div>- ✓Correct answer: Pass an array or object to
class; Svelte combines them like theclsxlibrary - 2Only with the
class:active={isActive}directive - 3With
classNamelike in React
Explanation
Objects and arrays in class are supported since Svelte 5.16. The class: directive still works but is no longer the recommended approach.