Card-Mod Help With Icon Color

Hey All,

I’m currently using the card-mod repo to change the color of the text in a card depending on the state. What I can’t figure out is how to get the icon to change colors as well. I see how to change it to one color that will always display but not how to make it change colors with the text. Here is the code I have to change the text:

  - entity: sensor.allergy_index_today
    card_mod:
      style: |
        :host {
          color:
            {% if states(config.entity) | int <= 2.4 %} 
              green
            {% elif states(config.entity) | int <= 4.8 %}
              greenyellow
            {% elif states(config.entity) | int <= 7.2 %}
              yellow
            {% elif states(config.entity) | int <= 9.6 %}
              orange
            {% elif states(config.entity) | int <= 12 %}
              red
            {% endif %}
            ;
        }

Thank you in advance for your time.

I’m on a similar quest. I believe using --card-mod-icon-color: will be part of doing what you’re asking. (Sorry for necro-posting, I just noticed your post was from a while ago)

I’m just toggling the icon on/off instead of using the device’s own RGB values, because when it’s on the rgb(255,255,255) being WHITE is invisible when using a white card background!