How can I apply style to a div based on condition in thymeleaf?
Solved it while posting the question,
th:style="${condition ? 'display:block' : 'display:none'}" >
would produce the necessary conditional style. If condition is true display is set to block and none if condition is false.
For admin,
th:style="${role == 'ADMIN' ? 'display:block' : 'display:none'}" >
the style is set to display:block
and for other roles the block is not displayed.
In simple case it could be written as
<div th:style="${filed==null ? 'opacity:.3'}">