šŸ”¹ Card-mod - Super-charge your themes!

using

  styles:
    tooltip:
      - transition: opacity 0.5s

on all my button-card tooltips throughout the dashboards, I suddenly realize the tooltips on the main menu items are not using this. Having a look into the card-mod-theme variables I couldnā€™t find the right place (if at all possible) to add this to the main mods, to make the tooltips immediate.

Would anyone be able to help me out here?

Ive tried to add it to either of these:

        /* Set the color of the currently selected tab indicator. */
        ha-tabs {
          --paper-tabs-selection-bar-color: var(--text-primary-color);
        }
        /* Set the color of the currently selected tab indicator.
           Set size of the currently selected tab icon*/
        paper-tab[aria-selected=true] {
          color: gold;
          background-color: rgba(var(--primary),0.3);
          --mdc-icon-size: {{states('input_number.active_icon_size')}}px;
        }

but not successfullyā€¦they need an actual click for that. The tooltip is a hover

        app-header, app-toolbar {
          background: {{'radial-gradient(var(--primary-color),var(--card-background-color))'
                         if states('input_select.theme')|regex_search('(ight|Dark|Matrix)')
                          else 'var(--primary-color)'}};
          color: var(--text-primary-color);
          transition: opacity 0.5s;
        }

wont do it either, so. Its a bit frustrating to ā€˜guessā€™ what to do.

I previously used card-mod to increase the size of the icons in my header bar, but at some point I lost that change. I thought @Ildar_Gabdullin posted about it, but I cannot find that in here either.

How do you change the size of the header bar icons?

I do not remember about changing an iconā€™s size on a header.
But you may try it yourself using my examples of customizing a header:
card-mod thread ā†’ 1st post ā†’ link at the bottom ā†’ examples for themes

1 Like

I hide the search magnifying glass and 3-dot menu.

card-mod-root-yaml: |
    .: |
      app-toolbar > ha-icon-button {
        display: {{'none' if is_state('input_boolean.hide_admin','on')}};
      }
      app-toolbar > ha-button-menu {
        display: {{'none' if is_state('input_boolean.hide_admin','on')}};
      }

However, it doesnā€™t hide them in the Settings page.
I noticed a different path, (ha-panel-config vs. ha-panel-lovelace) but I donā€™t know how to approach it:

Settings page:

Main page:

Suggestions?

Iā€™m using this to change the color of a single card-mod popup:

              card_mod:
                style: 
                  ha-dialog$: |
                    div.mdc-dialog__surface {background: rgba(64,64,64,1.0) !important}

How do I modify that to insert into a theme to change the background for all of my popups? This suggests I just add ā€˜ā€“ā€™ in front of background, but that does not work. Iā€™ve tried a few other variations which also donā€™t work. Thanks.

I have a problem with inside light gray border lines - could You help me to entirely get rid off them?


My code atm:

cards:
  - cards:
      - cards:
          - entity: sensor.drukarka_3d_print_status
            name: CR-6 SE
            type: entity
            icon: None
          - entity: switch.gniazdko_drukarka3d_pietro
            hold_action:
              action: more-info
            show_icon: true
            show_name: false
            tap_action:
              action: toggle
            type: button
        type: horizontal-stack
      - entities:
          - entity: switch.drukarka_3d_led
        show_header_toggle: false
        type: entities
    mode: vertical
    type: custom:stack-in-card
  - card:
      cards:
        - entity: sensor.drukarka_3d_print_progress
          type: custom:bar-card
          color: null
          positions:
            icon: 'off'
            indicator: inside
        - entities:
            - entity: sensor.drukarka_3d_print_time_left
            - entity: sensor.drukarka_3d_print_time
            - entity: sensor.drukarka_3d_print_file
            - entity: sensor.drukarka_3d_current_z
            - entity: sensor.drukarka_3d_tool_0_target
            - entity: sensor.drukarka_3d_bed_target
          show_header_toggle: false
          type: entities
        - cards:
            - entity: switch.drukarka_3d_emergency_stop
              hold_action:
                action: more-info
              name: Stop
              show_icon: true
              show_name: true
              type: button
            - entity: switch.drukarka_3d_cancel_print
              hold_action:
                action: more-info
              name: Anuluj
              show_icon: true
              show_name: true
              type: button
            - entity: switch.drukarka_3d_pause_print
              hold_action:
                action: more-info
              name: Pauza
              show_icon: true
              show_name: true
              type: button
            - entity: switch.drukarka_3d_shutdown_system
              hold_action:
                action: more-info
              name: Wyłączenie
              show_icon: true
              show_name: true
              type: button
          type: horizontal-stack
      mode: vertical
      type: custom:stack-in-card
    conditions:
      - entity: binary_sensor.drukarka_3d_printing
        state_not: 'off'
    type: conditional
  - card:
      decimals: 1
      entities:
        - entity: sensor.drukarka_3d_tool_0_temperature
          name: Dysza
          show_state: true
        - entity: sensor.drukarka_3d_bed_temperature
          name: StĆ³Å‚
          show_state: true
      hours_to_show: 1
      name: Temperatura dyszy/ stołu
      points_per_hour: 120
      type: custom:mini-graph-card
    conditions:
      - entity: binary_sensor.drukarka_3d_printing
        state_not: 'off'
    type: conditional
  - entities:
      - entities:
          - entity: sensor.filament_temperatura
            name: false
        entity: sensor.filament_wilgotnosc
        icon: mdi:thermometer
        name: Temperatura/ wilgotność filamentu
        secondary_info: last-changed
        type: custom:multiple-entity-row
    show_header_toggle: false
    type: entities
type: vertical-stack

Thank you in advance for any help and info!

final challenge in my menubarā€¦

this is in full width:

but changing the window makes the text template cover all of my tab icons:

would there be any way to limit the space the text template can use to a fixed width, (and maybe scroll in that text)?

I am using an input_boolean to use that template:

      .: |

        /* Hide chevrons
        paper-tabs$: |
          .not-visible {
            display: none;
          } */

        /* Optionally set the three-dots transparency,
           to allow for a replacement template text. */
        ha-button-menu {
          color: {{'transparent' if is_state('input_boolean.menu_options_template','on')}}; /*var(--primary-color)*/
        }

        /* Optionally set a replacement template text. */
        ha-button-menu::before {
          content: "{{states('sensor.custom_header_template')}}";
          color: var(--app-header-text-color);
          visibility: visible;
          position: relative;
          top: 24px;
          white-space: nowrap;
        }

so, if it cant be done, I might be able to auto-turn_off that boolean based on the screen width?

hope you can have a look, thanks!

Why does

      card-mod-card-yaml: |
        .: |
          ha-card {
            margin-top: 50px;
            margin-left: 10px;
            margin-bottom: 50px;
            margin-right: 10px;
          }

apply to the first card of a dashboad differentlythan to the restk?

If I define margin-bottom and top, the first cards on a dashboard has larger margins than all the others.

Hi,

Is is also possible to show the value sof the secundairy entities under the primary?
Its in the mini-graph card

This i allready found to hide the times/dates:

            card_mod:
              style: |
                .info.flex .info__item .info__item__value {
                 display: none;
                }

ā€­image

using this works really nicely:

        /* Set the color of the currently selected tab indicator.
           Set size of the currently selected tab icon*/
        paper-tab[aria-selected=true] {
          color: gold;
          background-color: rgba(var(--primary),0.3);
          --mdc-icon-size: {{states('input_number.active_icon_size')}}px;
        }

see the screenshots in my post a few above

Hi guys,

I need help with this if statementā€¦it is not working. Why?

elements:
  - entity: sensor.latest_grade_adam
    style:
      color: white
      font-size: 3rem
      text-align: center
      padding-top: 38%
      height: 100%
      left: 50%
      top: 50%
      width: 100%
    tap_action:
      action: more-info
    type: state-label
  - entity: sensor.latest_grade_adam
    attribute: subject
    style:
      background-color: rgba(0, 0, 0, 0.3)
      bottom: 0
      color: white
      font-size: 11px
      left: 0
      line-height: 2px
      text-align: center
      transform: initial
      width: 100%
    tap_action:
      action: more-info
    type: state-label
image: /local/unavailable.png
card_mod:
  style: |
    ha-card {
      min-height: 60px !important;
    }
    hui-state-label-element {
      background-color: 
      {% if (states(sensor.latest_grade_adam) > 3) %}
        rgb(60, 179, 113)
      {% else %}
        rgb(60, 279, 113)
      {% endif %}
    }
type: picture-elements

try it with a conversion '{% if (states(sensor.latest_grade_adam)|int(default=0) > 3) %}`

Thanks for reply! Not working though :frowning:

Ok I fixed it. There where ā€™ missing arround sensor.latest_grade_adam

yep. thatā€™s one of the easier aspects of card_mod, it uses regular jinja templates you can/should always check in the dev tools/template.

right, so after initial succes downgrading to 3.1.4 and see the icon mods in the tabs work properly again and change based on templates like:

      paper-tab[aria-label='Verwarming'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {% set action = state_attr('climate.front_room','hvac_action') %}
                           {{'mdi:radiator' if action == 'heating' else
                             'mdi:radiator-disabled' if action == 'idle' else
                             'mdi:radiator-off'}};
        }

Ive now updated to HA 2022.12.0b2, and the icons wont change any longer.

The template still is fineā€¦

anyone else seeing changes/issues in this regard?
Is it card-mod, or is it HA Frontendā€¦

update

Thought is was fixed updating to 2022.12.0b3 and saw the tab icons change correctly. However, updated to 12.0b4 and as of this morning the icons are again fixed, and not responding to the templates in card-modā€¦

its the same on ll of my tabs, icon doesnt change, icon color does:

      paper-tab[aria-label='Beweging'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {{'mdi:motion-sensor' if is_state('binary_sensor.motion_sensors_all','on') else
                             'mdi:motion-sensor-off'}};
          color: {{'red' if is_state('binary_sensor.motion_sensors_all','on')}};
        }

@arganto please forgive my tag, but youā€™re the one I remember having discussed several menu-items toggle with me.

        mwc-list-item[aria-label="Zoeken"] {
          {% if is_state('input_boolean.hide_search','on') %}
          display: none;
          {% endif %}
        }

doesnt work, because there is no label on the Search item. Would you know another way to do so? Meanwhile Ill ask Philip if the menu item an get a label :wink:

Can you point me to place/DOM, where I can find it? Then I have less to search.

that would be

#layout > app-header > app-toolbar > ha-button-menu > mwc-list-item:nth-child(2)```

although the silliest thing just happened: the mdi:loupe now doesnt show anymore, nor does the menu item ā€˜Searchā€™ā€¦ huh

So you are talking about the mobile/slim view, where the search you want to hide is in threedotmenu?
Then you can use e.g. the path you have posted, the child(2)-way. If this is always the case this way.

Didnā€™t we have exactly this already in the past? :joy: At least I have this already commented out in my theme from the last tests for you.

Yes, I thought so too but then I saw the Search item pop up and figured something might have changed ā€¦