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

It is centered. Probably you need to remove top padding for the bottom part of the footer (which is below the divider).

thank you Ildar. I am really trying to understand what you’re saying, but sorry I dont…
this is the full card:

type: entities
title: Speedtest
card_mod:
  class: class-header-margin
  style:
    hui-buttons-header-footer $ hui-buttons-base $ : |
      .ha-scrollbar {
        justify-content: center;
        height: 40px;
        align-content: center;
        margin: 0px;
      }
entities:
  - type: custom:mini-graph-card
    card_mod:
      style: |
        ha-card {
          box-shadow: none;
          margin: -8px -16px -16px -16px;
        }
    align_state: center
    icon: mdi:speedometer
    entities:
      - entity: sensor.speedtest_download
        name: Download
        color: green
      - entity: sensor.speedtest_upload
        name: Upload
        color: red
#          - entity: sensor.speedtest_ping
#            name: Ping
#            color: yellow
    show:
      extrema: true
      labels: true
      points: true
  - type: custom:fold-entity-row
    head:
      type: section
      label: Speedtest entities
      card_mod:
        style: |
          .label {
            margin-left: 0px;
          }
    padding: 0
    entities:
      - entity: sensor.speedtest_download
        name: Download
      - entity: sensor.speedtest_upload
        name: Upload
      - entity: sensor.speedtest_ping
        name: Ping
#      - type: button
#        name: Run Speedtest
#        tap_action:
#          action: call-service
#          service: speedtestdotnet.speedtest

footer:

  type: buttons
  entities:
    - entity: sensor.speedtest_download
      name: Run Speedtest
      icon: mdi:speedometer
      tap_action:
        action: call-service
        service: speedtestdotnet.speedtest

and this the result:

its almost what I want, and you can celerity see the ‘uncentered’ button in the footer.

if you say:

I am struggling to understand that. I did play with the paddings, even added padding-top: 0px; which at first sight does change it it, but, when looking more closely, simply cuts of the top of the button background:

which is odd, because padding: 0px should not cut it, but touch it?

but wait! this helps:

  style:
    hui-buttons-header-footer $ hui-buttons-base $ : |
      .ha-scrollbar {
        justify-content: center;
        height: 50px;
        align-content: center;
        margin: -8px 0px 0px 0px;
      }

its not the padding, but the margin that needs to be adjusted! and because of that, also the height.

image

    footer:
      type: buttons
      entities:
        - entity: sun.sun
          name: some very very very very long button
    card_mod:
      style:
        hui-buttons-header-footer $ hui-buttons-base $: |
          .ha-scrollbar {
            justify-content: center;
            padding-top: 0px !important;
          }

yeah, well, thats clearly off center:

compare that to:

Check MY screenshot - it is centered.
The “ha-scrollbar” is placed under the “divider” which has margins 16px.
Since you removed top padding from the “ha-scrollbar” & it has bottom padding 16px, the button becomes centered between divider & bottom edge.

Probably there are other reasons.

Just take this and test:

type: vertical-stack
cards:
  - type: entities
    entities:
      - sun.sun
      - type: custom:fold-entity-row
        padding: 0
        head:
          entity: sun.sun
        entities:
          - sun.sun
          - sun.sun
    footer:
      type: buttons
      entities:
        - entity: sun.sun
          name: some very very very very long button
    card_mod:
      style:
        hui-buttons-header-footer $ hui-buttons-base $: |
          .ha-scrollbar {
            justify-content: center;
            padding-top: 0px !important;
          }

uhm, I didnt?

that works ok:

maybe its the height I set? Let me try that.

Not literally “you”. This is just a translation from Russian.
Means - “if someone did A and then did B, then …”

1 Like

yep, thats it changing the height takes the button off-center:

          card_mod:
            style:
              hui-buttons-header-footer $ hui-buttons-base $: |
                .ha-scrollbar {
                  height: 50px;
                  justify-content: center;
                  padding-top: 0px !important;
                }

btw why use the vertical-stack, its not needed:

    - type: entities
      entities:
        - sun.sun
        - type: custom:fold-entity-row
          padding: 0
          head:
            entity: sun.sun
          entities:
            - sun.sun
            - sun.sun
      footer:
        type: buttons
        entities:
          - entity: sun.sun
            name: some very very very very long button
      card_mod:
        style:
          hui-buttons-header-footer $ hui-buttons-base $: |
            .ha-scrollbar {
              height: 50px;
              justify-content: center;
              padding-top: 0px !important;
            }

yields the exact same result

It’s left from my test. Each test has a description in a markdown card placed above the test card in the stack.

Get rid of it.

no, it’s the whole purpose of this effort.

I find the height if the footer way too big, and want it to be close to the height of the fold. Or, even better, the height of the button plus top and bottom margin 8px.

Try to operate by paddings for “ha-scrollbar” + margins for “divider” instead of overall height.

I will.

just as another example for the use of this:

see the difference between regular button entities in the entities list, and the footer. Ive not yet added the additional styling, this is more of an exercise for the spacing.

  - type: entities
    title: Soundbites
    card_mod:
      class: class-header-margin
      style:
        hui-buttons-header-footer $ hui-buttons-base $ : |
          .ha-scrollbar {
            justify-content: space-evenly;
            height: 50px;
            align-content: center;
            margin: -8px 0px 0px 0px;
          }
    show_header_toggle: false
    entities:
      - input_select.sound_bite
      - input_select.sound_bite_player
      - input_number.sound_bite_volume
      - type: divider
      - type: custom:hui-element
        card_type: horizontal-stack
        cards:
          - type: custom:button-card
            entity: input_boolean.loop_sound_bite
            <<: &style_boolean
              show_name: false
              aspect_ratio: 4/1
              icon: >
                [[[ return (entity.state === 'on') ? 'mdi:restart' : 'mdi:restart-off'; ]]]
              styles:
                icon:
                  - color: >
                      [[[ return (entity.state === 'on') ? 'green' : 'var(--text-color)'; ]]]
              card_mod:
                style: |
                  ha-card {
                    box-shadow: none;
                  }

          - type: custom:button-card
            entity: script.play_sound_bite
            <<: &style_script
              show_name: false
              aspect_ratio: 4/1
              icon: >
                [[[ return (entity.state === 'on') ? 'mdi:stop' : 'mdi:play' ]]]
              styles:
                card:
                  - box-shadow: none
                icon:
                  - color: >
                      [[[ return (entity.state === 'on') ? 'red' : 'var(--text-color)'; ]]]
              tap_action:
                action: call-service
                service: script.toggle
                service_data:
                  entity_id: entity
                haptic: light
              hold_action:
                action: more-info
                haptic: light

    footer:

      type: buttons
      entities:
        - entity: input_boolean.loop_sound_bite
          name: Loop Soundbite
        - entity: script.play_sound_bite
          name: Play soundbite
          icon: mdi:play

  - type: entities
    card_mod: *header
    title: Tunes
    entities:
      - input_select.tune
      - input_select.tune_player
      - input_number.tune_volume
      - type: divider
#      - type: buttons
#        entities:
#          - input_boolean.loop_tune
#          - script.play_tune
      - type: custom:hui-element
        card_type: horizontal-stack
        cards:
          - type: custom:button-card
            entity: input_boolean.loop_tune
            <<: *style_boolean
          - type: custom:button-card
            entity: script.play_tune
            <<: *style_script

    footer:

      type: buttons
      entities:
        - entity: input_boolean.loop_tune
          name: Loop Tune
        - entity: script.play_tune
          name: Play tune
          icon: mdi:play

ofc, I could also change the height of the button cards in the entities list, but this was a quick fix, also trying to usage the core features as much as possible (I kind of like the visual difference of the footer entities opposed to the regular items

one more, adding some extra styling:

  - type: entities
    title: Intercom messages
    card_mod:
      class: class-header-margin
      style: &footer
        hui-buttons-header-footer $ hui-buttons-base $ : |
          .ha-scrollbar {
            justify-content: space-evenly;
            height: 50px;
            align-content: center;
            margin: -8px 0px 0px 0px;
            --ha-chip-background-color: var(--primary-color);
            --ha-chip-text-color: var(--card-background-color);
            --paper-item-icon-active-color: red;
            --secondary-text-color: var(--card-background-color);
          }
        hui-buttons-header-footer $ hui-buttons-base $ .ha-scrollbar ha-chip:
          $: |
            .mdc-chip {
              border: 1px solid green;
              border-radius: var(--ha-card-border-radius);
            }


I’ve added the chip border merely for syntactical checks, so I know it is the correct place for the element.

Not sure though is the Paths are as efficient as could be?

Hello,
I am trying to make transparent the background of the card “auto-entities” but with no luck.

What am I doing wrong ?

- type: vertical-stack
  cards:
      - type: custom:auto-entities
        card:
          type: entities
          style: |
            ha-card: {
              background: transparent;
              }
        filter:
          include:

Thank you.

Remove “:”

It doesn’t work. Here my full configuration:

  - type: vertical-stack
    cards:
      - type: custom:auto-entities
        card:
          type: entities
          style: |
            ha-card {
              background: transparent;
              }
        filter:
          include:
            - domain: device_tracker
              options:
                type: custom:template-entity-row
                icon: mdi:network-outline
                secondary: >-
                  {{ as_timestamp(states[config.entity].last_changed)|
                  timestamp_custom('%X - %d/%m/%Y') }}
                state: >-
                  {{state_attr(config.entity, 'ip')}} |
                  {{state_attr(config.entity, 'mac')}}
                style: |
                  :host { 
                  {% if is_state('this.entity_id', 'home') %} 
                      color: yellow
                  {% endif %}                 
                  }
          exclude:
            - state: unknown
            - state: unavailable
        show_empty: false
        sort:
          method: friendly_name

This is not important.
Your auto-list may include only “sun.sun”, the style should work.
Put “red” instead of “transparent”.

And for better compatibility - specify “card_mod” keyword.

@Ildar_Gabdullin Thank you so much! With card_mod it works.

          card_mod:
            style: |
              ha-card {
                background: transparent;
                }

I never use card_mod and I never had any problems but it is good to know that it is better specify this keyword for better compatibility.

Let’s consider “you MUST use this keyword” version))