Add CSS class based on condition in Thymeleaf
Question:
How to add CSS class based on condition in Thymeleaf? Answer:
<div class="panel" th:classappend="${isFiltered} ? '' : 'filtered' ">
Description:
There is also a specific appending attribute in the Standard Dialect: the th:classappend
attribute, which is used for adding a CSS class to an element without overwriting the existing ones.
Reference:
Class appending reference
Share "How to add CSS class based on condition in Thymeleaf?"
Tags:
classappend, condition based class, css class, thymeleaf, add class Technical term:
Add CSS class based on condition in Thymeleaf