--- title: Classes --- Like any attribute, the `class` attribute can be set using regular JavaScript. Suppose we had an `active` class that we wanted to apply to an element when `isActive` is true — we could do it like this: ```html

red if active

``` That's a little verbose though, so the `class:` directive gives you a simpler way to achieve the same thing: ```html -

red if active

+

red if active

``` As with any directive, you can use any JavaScript expression. If it's a variable name that matches the class name, you can use a shorthand: ```html -

red if active

+

red if active

```