Conditional Classes
Adding a property with the name class:classname={...}
will show the classname only if the value is truthy.
let state = $state({
active: true,
});
let element = html`<div class="container" class:active=${use(state.active)}>Hello, world!</div>`;
let state = $state({
active: true,
});
let element = <div class="container" class:active={use(state.active)}>Hello, world!</div>;