You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `class:` directive is a convenient way to conditionally set classes on elements, as an alternative to using conditional expressions inside `class` attributes:
6
+
7
+
```svelte
8
+
<!-- These are equivalent -->
9
+
<div class={isCool ? 'cool' : ''}>...</div>
10
+
<div class:cool={isCool}>...</div>
11
+
```
12
+
13
+
As with other directives, we can use a shorthand when the name of the class coincides with the value:
14
+
15
+
```svelte
16
+
<div class:cool>...</div>
17
+
```
18
+
19
+
Multiple `class:` directives can be added to a single element:
0 commit comments