Vue udostępnia specjalną składnię obiektu i tablicy dla :class i :style, aby warunkowo stosować klasy i style inline na podstawie stanu reaktywnego — czystsze niż ręczne budowanie ciągów klas.
Składnia obiektu dla :class — przełączaj klasy warunkowo
<script setup>
import { ref } from "vue";
const isActive = ref(true);
const hasError = ref(false);
</script>
<template>
<!-- a class is applied when its value is truthy -->
<div :class="{ active: isActive, 'text-red': hasError }">...</div>
<!-- renders class="active" (active=true, text-red=false) -->
</template>
