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

No, do not have this option.

Merry Christmas everyone! I need a bit of help :slight_smile:

Iā€™m trying to create a custom theme and use the card mod to style the .primary span inside a ha-tile-info component thatā€™s inside the ha-card component.

I can achieve this by editing the tile card directly and add the following:

type: tile
entity: switch.bedroom1_switch1_btn1
card_mod:
  style:
    ha-tile-info$: |
      .info .primary {
        color: red;
      }

How can achieve the same thing inside a theme? I tried creating a custom theme and adding the card-mod-card styles as shown bellow but itā€™s not working.

frontend:
  themes:
    custom:
      card-mod-theme: custom

      card-mod-card: |
        ha-card {
          ha-tile-info$: |
            .info .primary {
              color: red;
            }
        }

Please ask in card-mod-theme thread.

thanks. i reposted there

Good morning, Iā€™m trying to make a glance card with a larger font than standard. As others posted, when the font gets too large, the overflow setting cuts off the text. Also as mentioned here, I can manually deselect overflow: hidden in the inspector, but adding overflow: visible to the card has no effect. I also tried increasing the card size, but that doesnā€™t change the size at all in HA.

The previous overflow questions had no solution. Has anyone figured a way around this? Is there a better card (such as custom button card) that would work here? I want a large, color-coded temperature to let us know if itā€™s time to add wood to our outdoor wood boiler. Code and screenshot below:

show_name: false
show_icon: false
show_state: true
type: glance
entities:
  - entity: sensor.heatmor_temperature
    card_mod:
      style: |
        :host {
          color:
            {% if states(config.entity) | int <= 110 %} 
              blue
            {% elif states(config.entity) | int <= 120 %}
              yellow
            {% elif states(config.entity) | int >= 110 %}
              red
            {% endif %}
            ;
        }
title: HeatMor
card_mod:
  style: |
    ha-card {
    font-size: 3em;
    cardHeight: 900px; # no effect
    overflow: visible; # or overflow: visible !important, no effect
    }

image

Because cardHeight is not css propertyā€¦ :sweat_smile:}
use line-height: 100%;

Hello and Merry Christmas!

Is there any way to move the Temp Value lower???

I use line-height: 100%;

but I still want to move it a bit down

What exactly do you mean? Do you mean the state or the whole ha-card? Does line-height work for you?

sameā€¦
use

ine-height: 100%;

That did the trick, thank you! Now I need to go add wood since itā€™s in the yellow!
image

Another CSS selector questionā€¦

Iā€™m trying to make the grid width in the built-in grid card smaller. Iā€™ve narrowed down this value:

grid-template-columns: repeat(var(--grid-card-column-count,2),minmax(0,0.5fr)) !important;

As being what I need to set. The DOM navigation here seems simple, but I cannot get it to work.

div ID ā€œrootā€ is what I want, as you can see here:

Assuming that hui-grid-card is the base, the following code should work:

card_mod:
  style:
    hui-grid-card $: |
      #root {
        grid-template-columns: repeat(var(--grid-card-column-count,2),minmax(0,0.2fr)) !important;
        }

But it doesnā€™t. Iā€™ve tried .:, and just going for #root, and several other variations. It seems that it has to be either hui-grid-card, or #root. What else would the selector be?

[sneaky edit: Also happy holidays everyone :christmas_tree: , I swear I have a lifeā€¦this is what I do for fun. :smiley: ]

Maybe read the documentation first? :slight_smile:

1 Like

Congratulations on noticing something I missed. After a long time trying a bunch of different solutions and reading different threads for hours, itā€™s reassuring to be reminded that Iā€™m actually a moron who just needed to ā€œread the documentation firstā€.

But in a roundabout way, youā€™ve answered my question, so thank you for responding and helping.

Nobody said that you are a moron, that was your own conclusion. And yes, users must read Docs.

gettting back to the 2025.1 changes in the card mods, I can confirm that setting a generic background here:

type: entities
card_mod:
  style:
    hui-sensor-entity-row:
      $: |
        hui-generic-entity-row {
          height: 25px;
          padding: 0px 16px;
          border-radius: var(--ha-card-border-radius);
          border: 1px groove var(--primary-color);
          background: green;
        }

does work (albeit for all generic-entity-rowā€™s of course)

still figuring out why a mod on the individual row does notā€¦

and its getting worse:

          - entity: script.intercom_text_message
            name: Speel bericht
            card_mod:
              style: |
                :host {
                  --card-mod-icon-color:
                    {% set state = states(config.entity) %}
                    {{'var(--alert-color)' if state == 'on' else 'var(--success-color)'}};
                  --card-mod-icon:
                    mdi:{{'stop' if state == 'on' else 'play'}};
                }

has completely lost itā€™s functionalityā€¦ many more. like this:

          - entity: input_text.message
            name: Bericht
            card_mod:
              style:
                hui-generic-entity-row $: |
                  state-badge {
                    display: none;
                  }

o dear. weā€™re in for a surprise next weekā€¦

all we know is they ā€˜changed some attributesā€™ ā€¦

opened this issue in card_mod

cold this be relatedā€¦? Update hui-generic-entity-row.ts Ā· dhoeben/frontend@6e810d4 Ā· GitHub

But I really think you didnā€™t read the documentation, maybe you just copied the first example from the repoā€¦ then you modified the style according to yourself, regardless of how card_mod works. The creator of the plugin didnā€™t write the readme just for funā€¦ so, RTMFā€¦ :pray:

I am still having a cosmetic issue with this glance card:

show_name: false
show_icon: false
show_state: true
type: glance
entities:
  - entity: sensor.heatmor_temperature
    card_mod:
      style: |
        :host {
          font-size: 4em;
          line-height: 100%;
          color:
            {% if states(config.entity) | int <= 110 %} 
              blue
            {% elif states(config.entity) | int <= 120 %}
              yellow
            {% elif states(config.entity) | int >= 110 %}
              red
            {% endif %}
            ;
        }
title: HeatMor

Frequently the mobile app displays the number with no formatting as shown below. Changing to a different tab and back to home or editing and saving (without changes) the card will once again display the larger, color-coded font. Is there something else I need to change so that what you see below doesnā€™t happen?

HI, having searched for a few hours, I cannot find a way to change an element in SVG.
The basis is a apexcharts which shows so-called ā€˜extremasā€™, here 15.9 and 12.1

image

I have been able to change the font size by referring to the class

card_mod:
  style: |
    ha-card     
      .apexcharts-point-annotation-label {
        font-size: 20px
      } 

What I want to achieve is to change the height/background of the <rect> elements but I just cannot find the path to it. This main class .apexcharts-point-annotations has two ā€˜rectā€™ and both need to follow the same sizing and coloring.
Any idea on how to address this?

EDIT: for those that did not come to the conclusion yetā€¦ I have very limited ā€˜skillsā€™ in this area :slight_smile:

I donā€™t think youā€™re able to target elements with an SVG tag, so your only real option is to manipulate existing classes used within that SVG element. So, you need to do something similar you did for the font size, but thereā€™s no class on the rect element.