Change color of text based on state value

(this is an exemple for a badge)

style: |
   :host { 
   color: {% if is_state('switch.light', 'on') %} yellow {% else %} grey {% endif %};
    --label-badge-red: {% if is_state('switch.light', 'on') %} yellow {% else %} grey {% endif %};
   }

something that look like that .
to help you:

and
https://www.w3schools.com/css/

3 Likes