🔹 Card-mod - Add css styles to any lovelace card

Also, the 2nd example will not work with picture-elements for styling an element. So, again we should use the 1st type (card_mod → style → …)

1 Like

I have to first apologize if someone has already covered this as I must be failing on how to search and cannot seem to find an answer / example and my guessing is not working.

I have a button that I cannot seem to find a way to change the font size of the “state” or would it be “operation” or “setting” or ??? text.

image

When pressed it pops open my thermostat in the Kitchens settings

image

I am trying to increase the font-size of the “Heat” text in this button and I thought it might be reffered to as the “state”, however, in the control panel that pops open it is called “Operation”.

Here is what I have, less all my attempts to add a font-size change for the text that shows now as “Heat”.

                  - type: button
                    tap_action:
                      action: more-info
                    entity: climate.kitchen
                    show_name: false
                    show_state: true
                    show_icon: true
                    icon: mdi:fan
                    icon_height: 25px\
                    card_mod:
                    style: |
                      ha-card {
                        border-radius: var(--border-radius);
                        box-shadow: var(--box-shadow);
                      }

I’ll keep searching the 2400 plus posts while I hope someone knows the answers I seek…

Thanks…

Thank you both - noted and changed in code.

Can you help me?

Trying to change the standard card https://pastebin.com/5fUNmPWH

Summary

But out of all css blocks only this ha-card {} is applied. And in blocks:
ha-card .header .name {}
ha-card .info .value {}
ha-card .info .measurement {}
For some reason, nothing is applied at all.

Plus, there is an additional question regarding the icons in this card, in particular, I would like to apply a code like this to it:

      img_cell:
        - background-color: rgba(var(--color-theme),0.05)
        - border-radius: 50%
        - place-self: center
        - width: 42px
        - height: 42px

Thank you.

You got a mixed code - Entities card + card_mod for Entity card.

    ha-card {
      border-radius: 20px;
      #font-weight: bolder;

Do not use “#” here since you are trying to comment a part inside a string.

This is for custom:button-card (ref this thread).

If you are talking about “may I apply a similar code for an entity icon” - ok, just a minute.

may be achieved:

type: entities
show_header_toggle: false
entities:
  - entity: sun.sun
  - entity: sun.sun
style: |
  ha-card {
    --mdc-icon-size: 60px;
  }

As for this:

already applied for icons.
As for this:

you can change a background:

type: entities
entities:
  - entity: sensor.cleargrass_1_co2
    card_mod:
      style:
        hui-generic-entity-row $: |
          state-badge {
            background-color: aqua;
          }

изображение

1 Like

Thank you for help. Here’s what I got.

Без имени

Similarly to this:
изображение
but with less efforts and only for static headers:

    type: entities
    entities:
      - type: custom:multiple-entity-row
        entity: sun.sun
        style: |
          :host .entity {
            display: flex;
            flex-direction: column-reverse;
          }
        entities:
          - entity: sun.sun
          - entity: sun.sun
          - entity: input_boolean.test_boolean
            toggle: true
        name: Bottom headers
        show_state: false

изображение

1 Like

If anyone needs this:
изображение

type: entities
show_header_toggle: false
entities:
  - entity: input_boolean.test_boolean
    name: normal
  - entity: input_boolean.test_boolean
    name: toggle on the left
    card_mod:
      style:
        hui-generic-entity-row $: |
          state-badge {
            display: none;
          }
        .: |
          hui-generic-entity-row {
            flex-direction: row-reverse !important;
          }
2 Likes

What about shortcuts in mini-media-player?
Like this:

shortcuts:
  attribute: sound_mode
  buttons:
    - icon: mdi:monitor-cellphone-star
      id: Любимая музыка
      type: command

Color for play-control buttons - ok, i find it.

Summary

I realy use search, but don’t find solution. Thanks again *смайл_пожатия_рук

Never used shortcuts, cannot give a ready solution.
Try to adapt ready styles for these buttons.

1 Like

Using card-mod to move a graph for the 2nd sensor to the bottom:
post
изображение

1 Like

Hmm, it turned out to be very simple, but it is possible that other elements will be painted as well.

type: custom:mini-media-player
entity: media_player.yandex_station_lb00000000000000304600006f6ab3ee
shortcuts:
  attribute: sound_mode
  buttons:
    - icon: mdi:monitor-cellphone-star
      id: Любимая музыка
      type: command
      ......
  columns: 6
card_mod:
  style: |
    ha-card {
      color: var(--state-icon-color) !important;
    }

color: var(–state-icon-color) !important;

Без имени

No, this attribute is TOO common, should not be used just to change icons…

I didn’t find any other way/variant :roll_eyes:
mmp-shortcuts__buttons
mmp-shortcuts__button
do not change color :roll_eyes:

Summary

Saw this error in the chrome console, anyone know what it is and how to fix it? Maybe this is the the reason that some of the style are not working. Thanks!

Failed to execute 'define' on 'CustomElementRegistry': the name "mod-card" has already been used with this registry at https://xxxxxx.duckdns.org/hacsfiles/lovelace-card-mod/card-mod.js?hacstag=190927524311:6:10674

Post a code with your attempts here - at least it will show people that you’re really trying hard ))).
I mean with using DOM navigation, not just setting a global color property.
We’ll see what is wrong there.

I hope someone can help me with problem I have been struggling with, creating my first dashboard.
I have absolutely no experience with CSS or HTML, but I am trying to learn…

I am simply trying to decrease the spacing between text lines in the Entities card (or rather, decrease the height of that “box”), hoping to make the overall card more compact.
Does anyone have a solution for that?

type: entities
view_layout:
  column: 1
entities:
  - entity: sensor.sm_t510_battery_level
    name: Batteri
  - entity: binary_sensor.sm_t510_is_charging
    name: Ladestatus
  - type: divider
  - entity: sensor.sector_stue_24000553b73
    name: Temperatur Stue
  - entity: sensor.sector_gang_2400055381c
    name: Temperatur Gang
state_color: false
show_header_toggle: false
tap_action:
  action: none
style:
  .: |
    ha-card {
      background-color: transparent;
      box-shadow: none;
      margin-bottom: -20px;
      margin-top: -30px;
      margin-left: -30px;
      width: 300px;
          }

Did you check the first post in this thread? There is a link at the bottom with many card-mod examples. Go through that list, maybe you’ll find a solution.

2 Likes

Any Card-mod gurus able to help me on this? I’m trying to target this state-switch <div> to set overflow: visible so that the background colour/image can ‘escape’.

This is what it currently looks like:

This is the desired look:

This is the <div> I can target with overflow: visible to make it work under styles #root {}:

I’ve attempted to wrap the state-switch-card within a custom:mod-card but I’m not sure if this is the correct approach?

thanks!

YAML
      - type: custom:stack-in-card
        view_layout:
          grid-area: main1
          justify-self: middle
          show:
            mediaquery: '(min-width: 600px)'
        card_mod:
          style: |
            #root {
              overflow: visible !important;
            }
            :host {
              margin-top: -300px !important;
              padding-top: 300px !important;
              overflow: visible !important;
              margin-left: -4px !important;
              }
            ha-card {
              background-color: rgba(0,0,0,0) !important;
              backdrop-filter: blur(0px) !important;
              border-radius: 30px 30px 30px 30px !important;
              box-shadow: none !important;
              overflow: visible !important;
              }
        cards:
          - type: custom:mod-card
            card:
              type: custom:state-switch
              entity: hash
              transition: slide-left
              transition_time: 500
              view_layout:
                grid-area: main1
              states:
                kitchen:
                  type: custom:layout-card
                  layout_type: grid
                  view_layout:
                    grid-area: main1
                  layout:
                    grid-template-columns: auto 300px 300px auto
                    grid-template-rows: 1fr
                  cards:
                    - type: custom:mini-media-player

Thank you. I did read through the examples in that post, but unfortunately I could not find something relevant to my specific case