Because I donāt really know how it works, itās a hit&miss procedure until it works . Too complicated for my brainā¦
My problem is that I canāt change badge-container color, border and background as easy as the --label-badgeā¦ in the different states provided by :host {%ifā¦
Itās OK, the āhit&missā procedure exactly what is used by lots of people (including me who never dealt with CSS before card-mod).
The link I gave you earlier explains that there are 2 ways of styling some element:
By defining CSS properties for some PARTICULAR element (ādirect access wayā) - and you need to specify a PATH to this element.
By defining special variables like āālabel-badge-text-colorā (āvariable wayā) for the whole badge (which can be addressed as ā:hostā). In a code of HA some properties of some elements are defined based on similar variables, and a user do not have to know a path to some element, he only need to define a corr. variable on a particular badge level or globally in a custom theme.
This is applicable for many UI parts, not to badges only. And to style some UI part sometimes a combination of both ways is used.
In the link given earlier both ways (ādirectā, āvariableā) are illustrated by examples.
Your 1st code is based on a provided ādirect wayā example.
Your 2nd code (but with errors) is based on a ācombinedā example.
Your task may be split:
Provide STATIC (w/o āifā) styles for elements.
Then - make some of these styles dynamic.
So, first prepare a STATIC styling.
Use the 1st code as a starting point (it seems to be correct).
Suggestion: use different colors to be sure that is styled properly, not like ālime for several elementsā.
It shows correct in the browser on my PC after coming from āRaw editā screen and if I hit refresh (F5) the page reloads and I donāt see the changed color.
On my Android phone I donāt see the changed color if I open the app.
Only sometimes after a refresh the colors are working.
May be not related, but if the condition is false then your code is
some_path {
some_property:
}
which causes an error. In most cases this is not critical, but this is not āsolidā.
See a few posts above HOW to properly wrap styles in āif elseā code.
Also, have you read this in part of āextra_module_urlā.
Try putting your code into Developer Tools > Template. It should highlight a couple of code errors:
{% if (states("sensor.temp_error_state").state == "Online" %}
youāve opened a bracket pair without closing it
states("sensor.temp_error_state") is all you need to return the sensor state. Adding .state means you are looking for an attribute of the state called state, which is obviously meaningless. This would only be needed if you were using the more long-winded square brackets notation i.e. states["sensor.temp_error_state"].state
Have a look in the dom on the right side. It is inside shadow root and not directly in ha-card. So you have to go one level deeper. Search for card-header in this thread. Asked and answered a lot of times.
Does custom:canvas-gauge-card belong to the list of cards that canāt be modified with card-mod? Iām using it within a picture_elements card so I can see <ha-card class="type-picture-elements"> when I inspect the card, but not within this for the gauge itself. The line before </canvas-gauge-card> is <card-mod slot='none'> and I am able to get things inserted into this section but they have no effect on the card size (Iām trying to adjust its height in response to the pc or phoneās screen size, either by explicitly re-stating the gaugeās size or by scaling it).
My experimental card (much simplified) yaml:
Hi its been a little bit, but since i am working on a guide for styling the tile card with card mod i figured i would give you a response.
it is unfortunately not possible to change the icons for most of the tile cards (any that have a feature) as they all use svg icons. card mod cant change these as far as i know @Ildar_Gabdullin may be able to confirm, or provide some insight on this. i have certainly been unable to do this.
you can however change the colors of the states like this (of coure pick your own colors )
I have only shown the 3 states because that is all my alarm panel supports right now, but all are included in the code
in the meantime if you are interested you can check out my mushroom card mod guide here. there are some overlaps on how things are styled in those and in the tile card. below