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

Thank you for the temp fix, will try out. Also thanks for researching and mentioning it is in fact a bug!

Hi, I tried that code in my theme, but it doesnā€™t work. I think itā€™s because I use a grid card and in there I have layout-card. Do you happen to know what the correct code might be? I tried changing hui-vertical-stack-card to some variations with grid and layout, but didnā€™t manage to get it t to work.

This is my basic dashboard setup:

  - title: Home 
    path: home
    type: panel
    icon: "mdi:home"
    badges: []
    cards:    
      - type: grid
        columns: 1 
        square: false   
        cards:
          -  custom:layout-card

The code I posted is for a simple case: a stack card on a panel view.
In other cases you will probably have to add alterations(

Thanks, this seems to be the correct code for grid-card, in case somebody else also comes across this

  card-mod-theme: theme-name
  card-mod-view-yaml: |
    hui-panel-view $: |
      hui-grid-card {
        --restore-card-border-shadow: 0px 2px 4px 0px rgba(0,0,0,0.16);
      }
      hui-grid-card > * {
        box-shadow: var(--restore-card-border-shadow) !important;
      }

Keep in mind, this not a solution, but just a bandaid. Since itā€™s using card-mod, itā€™s delayed when refreshing browser. So youā€™ll see the shadows get added in in a split second.

Hello forum :slight_smile:

maybe you can help me a bit.
I have created an entities-card, to each entity I have added an image.
Now I would like to get the image bigger.
How can I best realize this with card_mod?

type: entities
entities:
  - entity: sensor.abfallrestmuell
    image: /local/Bilder/Muelltonnen/restmuell.png
    name: ' '
  - entity: sensor.abfallgelbersack
    image: /local/Bilder/Muelltonnen/gelbersack.png
    name: ' '
    secondary_info: none
  - entity: sensor.abfallbio
    image: /local/Bilder/Muelltonnen/biomuell.png
    name: ' '

2024-06-14_08h04_45

Wrong thread, should be asked here.
This thread is for THEMES.

Off-topic: increasing an image size may cause increasing a whole rowā€™s height.
If you need to make the image more vivid - consider using a button-like card instead of Entities card.

Not sure if I am being a bit stupid! New to YAML, so I am trying to add a image to one of my dashboard cards instead of the name, when I add this below, i have created the file in the www/views/ folder which I created and has this:

title: ā€œRachel Test Tabā€
path: card-mod-themes-rachel

icon: mdi:car

badges:
cards:

views:

  • !include www/views/card-mod-themes-rachel.yaml

I get this error . I am sure I am doing something stupid!

Include works in yaml mode dashboards only.

@Ildar_Gabdullin / anyone - can someone give me a pointer as to how I might change the title of my view dynamically?

In my case Iā€™d like to adjust the ā€œHeatingā€ to be ā€œHeating :fire:ā€ when the heating is on.

image

How do I remove the 'unit_of_measurement from an entity in an entities card?

My example entities card now looks like this:
Power Card

The code for this card:

type: entities
title: Power [Watt]
entities:
  - entity: sensor.electricity_meter_power_consumption_phase_l1
    card_mod:
       style:
        hui-generic-entity-row:
          $: |
            state-badge {
              display: none;
            }
            .info {
              display: none;
            }
  - entity: sensor.electricity_meter_power_consumption_phase_l2
    card_mod:
      style:
        hui-generic-entity-row:
          $: |
            state-badge {
              display: none;
            }
            .info {
              display: none;
            }
  - entity: sensor.electricity_meter_power_consumption_phase_l3
    card_mod:
      style:
        hui-generic-entity-row:
          $: |
            state-badge {
              display: none;
            }
            .info {
              display: none;
            }

I want the card look like this:
Power Card Modified

In other words I want to remove the ā€˜Wā€™ indication and just have the numbers shown.
Have tried without success:

          .unit_of_measurement {
            display: none;
          }

and:

         .value {
         --secondary-text-color: transparent;
         }

How can I remove the ā€˜Wā€™ indication after the numbers for the unit of measurement?
Many thanks in advance.

this might be better served with another card, why eg not simply list those values in a Markdown if you want to hide everything, except a value?

Also, if you want to move to card-mod thread that would help you better, this is the card-mod-theme thread, and not about per card mods

I havent seen it done though, and

    card_mod:
      style:
        hui-generic-entity-row:
          $: |
            .text-content:not(.info) {
              display: none;
            }

hides both value and unit, because the unit does not seem to have its own element to mod.

reason to again to point to other solutions, in core use markdown,

or, in custom, use template-entity-row, and simply dont set a unit

  - type: custom:template-entity-row
    # name: []
    # icon: []
    state: >
      {{states('sensor.electricity_meter_power_consumption_phase_l3')}}

although that would list the value at the right side of the card, in its regular spot

Anyways, hop over to card-mod thread and get more assistance there

1 Like

Dear Marius [Mariusthvdb],

Thank you very much; I have used your ā€˜template-entity-rowā€™ solution.

Apologies for using the wrong thread.
I donā€™t see/know how to move my question to the card-mod thread; maybe a moderator can do this?

itā€™s fine, just use the other thread next time.
glad I could help you, thx for the feedback

1 Like

I had to completely EDIT my entire post because I got it working. I was trying to switch the sidebar to the left side, make it smaller, and scroll the main. It works as instructed so I must have been doing something wrong at first. My working code is at the bottom but unfortunately it still doesnā€™t do everything I would it to.

Iā€™m not sure that this would be the best place to ask this but is there anyway to use the sidebar layout along with the Grid (layout-car) by @thomasloven? Iā€™ve used other sidebar integrationā€™s but thereā€™s a lot of glitches with them. Iā€™d like to have a sidebar on every page which does not change. This sidebar seems to work fine but it doesnā€™t seem like I could use the Grid (layout-card) with it which is what Iā€™ve have my entire frontend setup with.

If not and besides just dealing with the other glitchy sidebar integrations, Iā€™ve tried using the Grid (layout-card) and the custom:declutter-card to make a sidebar which works but I need to find a way to keep the sidebar fixed in place. Can I use some type of theme or card-mod styling similar to what I have below to freeze the sidebar column in place (one column in the layout-card) and let the rest of everything scroll as normal?

Any suggestions?

side_bar_my_dark_theme:

  card-mod-theme: side_bar_my_dark_theme
  card-mod-view-yaml: |
    hui-sidebar-view $: |
      .container {
        flex-direction: row-reverse;
      }
    hui-sidebar-view:
      $: |
        .container div#main {
          max-height: calc(100vh - var(--header-height) - 4px);
          overflow-y: auto;
        }
        @media (max-width: 760px) {
          .container div#main {
            max-height: unset;
            overflow-y: unset;
          }
        }
        .container div#sidebar {
          max-width: 300px;
          width: -webkit-fill-available;
        }

@Ildar_Gabdullin instead of using the sidebar layout or one of the sidebar integrations, is there a way to just style a Grid (layout-card) so the left most column in the grid stays fixed but all of the other columns still scroll? Thanks.

I am not a css pro; imho you cannot make only a part of grid scrollable.
P.s. Please do not tag people, this is against rules.

Hi everyone, Iā€™m coming to you with a question somehow I canā€™t figure out why this is happening. I use for custom popup card with browser mod integration and in it I modify styles for css using card-mod.

I have one main theme for the whole system, which contains only basic variables for HA and a small part for card-mod-more-info-yaml configuration, for the dashboard I have another theme separately, which contains its own variables and another card-mod-view-yaml for a specific dashboard view.

Moving on to the problem, lately Iā€™ve been experiencing a little delayed response after opening a custom popup and css styles reload after with lag, depending on how much custom css is used in it. I donā€™t know if it happened before the card-mod update or after. To find out the cause of the problem in the dev tools where the error is, the cause of the delay is in the use of the card-mod module to modify the css popup content elements.

So I want to ask more experienced people if anyone has encountered and solved a similar problem, or advised how to properly use the css for the popup content with the browser mod without getting an error. Thank you in advance for your answersā€¦

Main theme
Main Theme
  card-mod-theme: Main Theme

  card-mod-more-info-yaml: |

    .: |
      ha-dialog {
        --vertical-align-dialog: var(--tablet-popup-align-dialog) !important;
        --dialog-surface-margin-top: var(--tablet-popup-margin-top) !important;
        --dialog-box-shadow: 0 0px 16px 4px rgba(101,115,134, .15), 0 16px 64px 32px rgba(101,115,134, .5) !important;
        --mdc-theme-surface: rgba(34,38,39,1) !important;
      }



      ha-dialog > div.content > div.container {
        padding: 0 !important;
      }
      @media (max-width: 800px), (max-height: 500px) {
        ha-dialog {
          --mdc-dialog-min-width: 100vw !important;
          --mdc-dialog-min-height: 100vh !important;
          --popup-border-radius: 0 !important;
        }
      }

      ha-dialog > div:focus {
        outline: none;
      }

    $: |
      .mdc-dialog__surface {
        background-color: var(--popup-background-color) !important;
        box-shadow: var(--dialog-box-shadow) !important;
      }

Popup dialog

action: fire-dom-event
browser_mod:
  service: browser_mod.popup
  data:
    title: MBPro Server
    card_mod:
      style:
        ha-dialog$: |
          :host {
              --ha-card-border-width: 0 !important;
              --ha-card-border-radius: 0px !important;
              --ha-card-border-color: none !important;
              --bar-card-border-radius: 12px !important;
              --ha-card-box-shadow: none !important;
              --ha-card-background: none !important;
              --mdc-theme-surface: rgba(34,38,39,1) !important;
          }
          .mdc-dialog__surface {
            background-color: var(--popup-background-color) !important;
          }
        layout-card:
          $grid-layout$:
            # card divider border
            .: |
              #root > * {
                margin: 0px !important;
              }
              @media (max-width: 450px), (max-height: 500px) {
                #root {
                  display: block !important;
                }
              }
            hui-entities-card:
              $: |
                ha-card {
                  border-right: 0.1vw solid rgba(58, 69, 73, 0.2);
                  border-radius: 0;
                  transition: none;
                }
                /* portrait */
                @media screen and (max-width: 800px) {
                  ha-card {
                    border-right: none;
                    border-bottom: 0.1vw solid rgba(58, 69, 73, 0.2);
                  }
                }
              $hui-horizontal-stack-card:
                $: |
                  #root {
                    justify-content: space-evenly;
                    margin-top: 1.7em;
                  }
            hui-entities-card:last-child:
              $: |
                ha-card {
                  border: none;
                }
    content:
      type: custom:layout-card
      layout_type: custom:grid-layout
      layout: !include ../../snippets/popup_footer_layout.yaml
      cards:

whole popop yaml codes
action: fire-dom-event
browser_mod:
  service: browser_mod.popup
  data:
    title: MBPro Server
    card_mod:
      style:
        ha-dialog$: |
          :host {
              --ha-card-border-width: 0 !important;
              --ha-card-border-radius: 0px !important;
              --ha-card-border-color: none !important;
              --bar-card-border-radius: 12px !important;
              --ha-card-box-shadow: none !important;
              --ha-card-background: none !important;
              --mdc-theme-surface: rgba(34,38,39,1) !important;
          }
          .mdc-dialog__surface {
            background-color: var(--popup-background-color) !important;
          }
        layout-card:
          $grid-layout$:
            # card divider border
            .: |
              #root > * {
                margin: 0px !important;
              }
              @media (max-width: 450px), (max-height: 500px) {
                #root {
                  display: block !important;
                }
              }
            hui-entities-card:
              $: |
                ha-card {
                  border-right: 0.1vw solid rgba(58, 69, 73, 0.2);
                  border-radius: 0;
                  transition: none;
                }
                /* portrait */
                @media screen and (max-width: 800px) {
                  ha-card {
                    border-right: none;
                    border-bottom: 0.1vw solid rgba(58, 69, 73, 0.2);
                  }
                }
              $hui-horizontal-stack-card:
                $: |
                  #root {
                    justify-content: space-evenly;
                    margin-top: 1.7em;
                  }
            hui-entities-card:last-child:
              $: |
                ha-card {
                  border: none;
                }
    content:
      type: custom:layout-card
      layout_type: custom:grid-layout
      layout: !include ../../snippets/popup_footer_layout.yaml
      cards:
        #################################################
        #                                               #
        #                HOME ASSISTANT                 #
        #                                               #
        #################################################
        - type: entities
          title: ' '
          show_header_toggle: false
          card_mod:
            class: header
          entities:
            - entity: binary_sensor.macbookpro
              name: Active
              state_color: true
            - entity: sensor.mbproserver_connection_type
              name: Connection
            - entity: sensor.mbpro_uptime_usage
              name: Uptime
            - type: custom:bar-card
              width: 55%
              height: 2em
              decimal: 0
              unit_of_measurement: '%'
              positions: &bar_card_positions
                icon: outside
                indicator: 'off'
                name: outside
              severity: &bar_card_severity
                - color: '#9da0a2'
                  from: 0
                  to: 59
                - color: '#9da0a2'
                  from: 60
                  to: 100
              entity_row: true
              entities:
                - entity: sensor.mbpro_cpu_usage
                  name: Processor
                - entity: sensor.mbpro_memory_usage
                  name: Memory
            - type: custom:hui-horizontal-stack-card
              cards:
                - type: custom:button-card
                  name: Lock
                  icon: mdi:lock
                  tap_action:
                    action: call-service
                    service: shell_command.lock_mbpro
                  template: icon_name
                - type: custom:button-card
                  name: Sleep
                  icon: mdi:power-sleep
                  tap_action:
                    action: call-service
                    service: shell_command.sleep_mbpro
                  template: icon_name
          footer:
            type: custom:mini-graph-card
            # name: Speedtest
            tap_action:
              action: call-service
              service: homeassistant.update_entity
              service_data:
                entity_id: sensor.mbpro_cpu_usage
            entities:
              - entity: sensor.mbpro_cpu_usage
                name: Processor
                color: '#00bb33'
              - entity: sensor.mbpro_memory_usage
                name: Memory
                show_state: false
                color: '#2196f3'
                y_axis: secondary
            hours_to_show: 48
            hour24: true
            line_width: 3
            animate: true
            # upper_bound_secondary: 100
            show:
              name: false
              icon: false
              state: false
              legend: false
              fill: fade
              labels: true
              labels_secondary: false
              average: false
              extrema: false
              points: hover

CleanShot 2024-06-24 at 18.43.25

You might not be a pro but you do have a lot more experience and knowledge about bout it than me. If I get stuck trying to style something, I always check to see what you say first because your below post on using the card_mod: has some of the best examples.

And I apologize for tagging you but the majority of the time thatā€™s how I begin my replies. I also never heard anyone say it was against the rules. The only thing Iā€™ve heard people say is not to tag someone in a topic that theyā€™ve never posted on because it sounds like youā€™re summoning themā€¦

So I just checked the rules and tagging is allowed, they just say to be polite and respectful when you do it. They only suggest not to do it because of the same reason that I just stated above. Either way, Iā€™ll make sure not to do it when it comes to your posts since you obviously donā€™t like it. Have a great dayā€¦

1 Like

You are always welcome to ask! If I can, if I am home, if my HA test machine is on - will try helping.

A possible way:
ā€“ layout card: a grid with 2 columns: vertical-stack + layout-card,
ā€“ the 2nd layout-card has a grid layout + card-mod for scrolling

1 Like

Iā€™m trying to use the theme features to reuse CSS for a mod-card that Iā€™m using to wrap many of my cards that otherwise start with vertical stacks. The class attribute does not seem to be applied to the card. This is the yaml, and the markdown ha-card gets the class applied, but not the mod-card. Should I be using something other than a mod-card?

type: custom:mod-card
card_mod:
  class: mod-card-wrapper
card:
  type: vertical-stack
  cards:
    - type: markdown
      content: Lampar
      card_mod:
        class: card-header

Edit: Trying to move this from mod-card to entities, but type: hui-markdown-card is not working.

Edit2: I just skipped the markdown card since all it was doing was acting as a title. Just used the entities card title instead and styled it the same.