Entity card w/ different colors depending upon numeric state?

I have a number of moisture senors that I want to display in a table, where the color of the displayed % changes depending upon the range, e.g., >80 would be green, and under 40% would be red, with yellow in between.

Can you suggest the best way to do this?

Hi,

I don’t know what you mean by “display in a table”?
With my temperature sensors I use a mushroom template card to change the color of the icon according to the current temperature. Maybe it helps…

type: custom:mushroom-template-card
primary: Temperature Livingroom
secondary: "{{ states('sensor.living_temperature') }}°C"
icon: mdi:sofa-outline
icon_color: >-
  {% set temp = states('sensor.living_temperature') %} {% if temp <
  '15' %} 
    blue-grey
  {% elif temp < '16' %}
    blue
  {% elif temp < '17' %}
    lime
  {% elif temp < '18' %}
    yellow
  {% elif temp < '19' %}
    amber
  {% elif temp < '20' %}
    orange
  {% elif temp < '25' %}
    deep-orange
  {% else %}
    red
  {% endif %}
entity: sensor.living_temperature
tap_action:
  action: more-info

afbeelding