Skip to main content

class:

The class: directive is a convenient way to conditionally set classes on elements, as an alternative to using conditional expressions inside class attributes:

<!-- These are equivalent -->
<div class={isCool ? 'cool' : ''}>...</div>
<div class:cool={isCool}>...</div>

As with other directives, we can use a shorthand when the name of the class coincides with the value:

<div class:cool>...</div>

Multiple class: directives can be added to a single element:

<div class:cool class:lame={!cool} class:potato>...</div>

Edit this page on GitHub

previous next
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy