šŸ”¹ Card-mod - Add css styles to any lovelace card

I had actually tried changing the margin in both the template and directly on the button and it didnā€™t do anything.

Iā€™ll give that a shot. Thanks

Alright, no problem. Thank you anyway! :+1:

just found the header link icon in history-graph cards, and tbh, it was unthemed, and didnt look nice at all.
So, I wanted to hide it, which works with display: none.
Add a boolean toggle, and control it from the UI.

next I needed it to be in style with my themes, so set primary-color on the icon. seems nice:

    .card-header ha-icon-button {
      --card-mod-icon-color: var(--primary-color);
      {{'display: none' if is_state('input_boolean.hide_history_graph_link','on')}};
    }

if would hope to find a theme variable for the icon, so we wont need to see it in a card_mod for each individual card.

Did anyone find that yet?

default icon:

no icon:

themed icon:

Hi Ildar, excelent work!

Ildar, Iā€™m trying to remove/hide without success the component

for "custom:more-info-card"

Iā€™ve also been trying for some time to reduce the height of the entire component by half.

Can you help me with this?

type: horizontal-stack
cards:
  - type: custom:more-info-card
    entity: light.spots_da_tv
    title: Spots TV
    card_mod:
      style: |
        ha-card {
          width: 150px;
          state-card-content {
            display:none;
          }
        }   

Can you post your code so folks can copy and paste it easily? It helps expedite solutions.

#11

After upadate Core,the color of this icon doesnā€™t work. this is a bug or am i wrong?

type: horizontal-stack
cards:
  - type: tile
    entity: sensor.aria_pm25
    name: PM 2.5
    show_entity_picture: false
    card_mod:
      style:
        .icon-container .icon$: |
          .shape { 
            border-radius: 15px !important;
            background:
              {% if states('sensor.aria_pm25')|float(0) >= 125|float(0) -%}
                rgba(255,0,0,0.6)
              {% elif states('sensor.aria_pm25')|float(0) >= 60|float(0) -%}
                rgba(255,165,0,0.8)
              {% elif states('sensor.aria_pm25')|float(0) >= 0|float(0) -%}
                rgba(60,179,113,0.6) 
              {% endif %} !important; 
          }
  - type: tile
    entity: sensor.aria_voc_index
    name: VOC Index
    icon: mdi:chart-bell-curve-cumulative

Noticed similar things occurring with tile card icons and animations since the update. Change:

.icon-container .icon$

with:

ha-tile-icon$

Has fixed some issues for me

1 Like

I think the DOM path has changed slightly, so that the tile icon element no longer has the .icon class. Try this to see if it works for you (it does for me):

    card_mod:
      style:
        .icon-container ha-tile-icon $: |

Actually, not sure you really need the .icon-container bit. Try this alternatively:

    card_mod:
      style:
        ha-tile-icon $: |

EDIT: gbboy got there first!

1 Like

yes, it is work!!! thank you

yes, this is the solution, itā€™s work! thanks

@hazio What card? Check out

Already answered what was changed.
Suggest you to use Code Inspector before posting issues in Github.
Now the repo is cluttered with plenty of ā€œbugsā€ (still open) which are ā€œusersā€™ errorsā€ in fact.

1 Like

Itā€™s for All cards, It needs to be applied system-wide, so Iā€™d imagine it will be through themes.

Edit: Okay, I think I have figured it out

--state-icon-error-color: var(--error-state-color, var(--error-color)); --state-unavailable-color: var(--state-icon-unavailable-color
  1. Try to understand how to fulfil your task for one card.
  2. Then - how to do it globally.

If you disagree with pt.1 - then the question should be asked in a themes thread )))

1 Like

iā€™m sorry, but i canā€™t work this out
the new update seems to have broken

card_mod:
          style: |
                ha-card {
                  --primary-text-color: white;
                  }

but only on one of my computersā€¦ which is why i am puzzled
any help would be appreciated

Does this fix it.?

card_mod:
    style: |
        ha-card {
          --card-primary-color: white !important;
                 }

What card?
And why not checking with Code Inspector by yourself?

Clean up cache everywhere.
If some style does not work on some device - it may happen because of:
ā€“ the device still have some old js-code in cache
ā€“ the device has a browser which does not support (or supports wrongly) some CSS attrs/features.

sorry for my error and thanks for the support.

1 Like

No need to apologize; understanding these things is for YOUR success.