Multiple ternery class bindings in Alpinejs

Viewed 15

Whilst looping through some links, I would like to apply classes to a element based on two ternery conditions, eg:

<a 
    :class="route.cond1 === true ? 'bg-red-500' : 'bg-green-500'
    :class="route.cond2 === true ? 'text-blue-500' : 'text-purple-500'"
>
    CLICK
</a>

How can I do this?

0 Answers
Related