So,
- The card displays a sensor.
- Tapping → toggling some switch.
- You need to colorize the card’s icon dependently on this switch.
Since
- the icon is for entity which is not a switch,
- and you need to use a standard “button” card,
then your only possible option is card-mod:
- type: button
entity: sensor.xxx
...
card_mod:
style: |
{% if is_state('switch.xxx','on') -%}
ha-state-icon {
color: var(--state-active-color) !important;
}
{%- endif %}
Suggest to ask all card-mod related questions in the huge card-mod thread.
Or consider using other cards/solutions (like one posted above).