#how to: css function to get rgb values from color (name/variable)

1 messages · Page 1 of 1 (latest)

violet salmon
#

looking for a way a to get the rgb values from a color name or theme variable, so I can set that, and use in rgb() And rgba() functions. We can use the rgb(from COLOR R G B /A ) function, but that does result in a final rgb(r,g,b) and not in the for me required r,g,b...real life example:

        card_mod:
          style: |
            hui-generic-entity-row {
              background:
                {% set perc = states(config.entity)|float(0) %}
                /*{% set rest = 100 - perc %}*/
                {% set bar = '0,0,0' %}
                /*linear-gradient(to left,ivory {{rest}}%, {{bar}} {{perc}}%);*/
                linear-gradient(to right, rgb({{bar}}) 0%, rgb({{bar}}) {{perc}}%,
                               rgba({{bar}},0.6) {{perc}}%, rgba({{bar}},0.2) 100%);
            }

which as you can see sets the r,g,b hard coded to '0,0,0' and next uses it in the linear-gradient. My hope is to replace the '0,0,0' with the var(--badge-color) so I can do this https://community.home-assistant.io/t/new-badges-and-card-mod-customisation/757488/69?u=mariusthvdb

thans for any css trickery you can help me with, or jinja for that matter.