Vue · Junior · Question 10 of 75

How do you toggle a CSS class based on a condition?

Explanation

:class accepts an object, an array or a string, and is merged with a static class attribute. :style works similarly with objects like { color: textColor }.

Further reading

Problem with a question

Vue · Junior · question 10

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz