It works like this:
type: entity
entity: input_boolean.style
style: |
@keyframes rotation { 0% { transform: rotate(0deg); }
100% { transform: rotate(359deg); } }
.header .icon {
{% if is_state('input_boolean.style','on') %}
animation: rotation 1.5s linear infinite;
{% endif %}
}
You’re welcome.