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

@image969 Assuming youā€™re talking about displaying a card via browser_mod.popupā€¦ thereā€™s no special card-mod configuration. The easiest way Iā€™ve found is to create the card you want to ā€œpop upā€ in a test dashboard via normal means. Get your card-mod setup and whatever else exactly how you want it, and then copy the yaml into your browser_mod.popup service call under your firedom event. If you copy/paste correctly, the popup will look exactly like the card in your test dashboard.

Hi, thanks for the reply. I have the card working fine in the pop-up. Itā€™s just a drop-down menu when you click on it. The pop-up dimensions arenā€™t big enough so it crops it. I want to know if the overflow in card mod can be used so it extends past the pop-up.

Canā€™t help much if you donā€™t post your current code, but you can definitely increase the height of the popup card which could solve your issue.

Hereā€™s a screenshot of the code I was referring to. I would rather not change the height of the pop-up card, because then there would be a ton of blank space showing when Iā€™m not using the drop-down menu. I have no problem with this overflow line anywhere else it just doesnā€™t seem to work Inside the pop-up card

I donā€™t think you can do that. The popup card has a defined size. You can change the size via card-mod etc, but itā€™s a defined size nonetheless. You canā€™t declare anything outside the size of the popup card as there just isnā€™t any space there. Itā€™s possible to add scrollbars, but thatā€™s going to let you scroll the whole card. I suppose itā€™s possible to add scrollbars to only the dropdown, but you would have to experiment with card-mod and it will depend on the specific card your trying to use and how itā€™s constructed. I could very easily be wrong, but Iā€™d be surprised if you can accomplish this with card-mod alone, at least as long as youā€™re talking about it being a popup card. In any case, if you donā€™t post your code properly formatted, then no one can help, as no one can copy and paste your code from a screenshot to try things and give you direction.

I was kind of thinking the same about not being able to escape outside of the pop up size. Here the code, if anyone is feeling bored lol

Please note, not everything will work correct, as this is one of 6 cards inside of a conditional setupā€¦ My only concern is when you click on the card, and see the pop up and drop down for the Pandora section

Thanks

type: custom:mini-media-player
entity: media_player.living_room_2
background: /local/echo2.jpg
tap_action:
  action: fire-dom-event
  browser_mod:
    service: browser_mod.popup
    data:

      content:
        type: custom:stack-in-card
        cards:
          - type: entities
            entities:
              - entity: input_select.content
                name: platform
                card_mod:
                  style:
                    hui-generic-entity-row $: |
                      state-badge {
                        display: none;
                      }
          - type: conditional
            conditions:
              - condition: state
                entity: input_select.content
                state: Pandora
            card:
              type: entities
              entities:
                - entity: input_select.pandora_stations
                  card_mod:
                    style:
                      hui-generic-entity-row $: |
                        state-badge {
                          display: none;
                        }
                - type: call-service
                  name: 'Pandora Radio '
                  icon: mdi:pandora
                  action_name: Play Music...
                  service: script.alexa_pandora_living
                  data:
                    - Pandora
              state_color: false
              show_header_toggle: true
          - type: conditional
            conditions:
              - condition: state
                entity: input_select.content
                state: Amazon
            card:
              type: entities
              entities:
                - entity: input_text.text
                  type: custom:text-input-row
                - type: call-service
                  name: 'Amazon Music '
                  icon: mdi:music
                  action_name: Play Music...
                  service: script.alexa_amazon_living
                  data:
                    - AMAZON_MUSIC
              state_color: false
              show_header_toggle: true
          - type: conditional
            conditions:
              - condition: state
                entity: input_select.content
                state: Apple
            card:
              type: entities
              entities:
                - entity: input_text.text
                  type: custom:text-input-row
                - type: call-service
                  name: Apple Music
                  icon: mdi:apple
                  action_name: Play Music...
                  service: script.alexa_apple_living
                  data:
                    - Apple
              state_color: false
              show_header_toggle: true
          - type: custom:mini-media-player
            entity: media_player.living_room_2
            group: false
            source: true
            info: true
            hide:
              icon: true
              volume: false
              power: true
              play: true
              source: true
              progress: true
              name: true
              stop: true
            volume_stateless: false
            toggle_power: true
            replace_mute: stop
            card_mod:
              style: |
                :host {
                  --mini-media-player-accent-color: #bfb6bd;
                  }
                ha-card {
                  overflow
                }
        card_mod:
          style: |
            ha-card {
              overflow: visible !important;
              
            }
            ha-card > div {
              overflow-x: clip;
            }
group: true
source: null
info: null
hide:
  icon: true
  volume: true
  power: true
  controls: true
  source: true
  progress: true
shortcuts:
  columns: 6
  buttons:
    - icon: mdi:sofa
      type: script
      id: script.alexa_livingroom
    - icon: mdi:pot-steam
      type: script
      id: script.alexa_kitchen
    - icon: mdi:toilet
      type: script
      id: script.alexa_bathroom
    - icon: mdi:movie-check
      type: script
      id: script.alexa_movieroom
    - icon: mdi:desk
      type: script
      id: script.alexa_office
    - icon: mdi:bed-king
      type: script
      id: script.alexa_bedroom
card_mod:
  style:
    mmp-shortcuts $: |
      mmp-button:nth-of-type(0) ha-icon {
        color: cyan;
      }
      mmp-button:nth-of-type(1) {
        background-color: rgb(50,50,50,.6);
      }
    style: |
      ha-card {
        height: 250px;
        }
tts:
  platform: alexa

(for ppl finding replied post via search, like I did):
For limiting ā€œhistory-graphā€ height, at least in HA 2024-3 the card supports variable ā€œchart-max-heightā€, it can be set on the root ha-card

ha-card {
   --chart-max-height: 80px !important;
}

kuva

1 Like

Hi, you have helped me with code more than anyone on a year ago in the mushroom forum so I hope you can help me again, cause Iā€™ve been struggling for a week lol

For a browser-mod pop-up card. I have a drop down menu inside. When I click on the drop down it gets cropped due to the height of the card. I have to scroll the entire card down. Is it possible using card_mod to do the overflow: visible to have the drop down extend past the pop-up? i cannot for the life of me get this to work

As a worse case scenerio, is it possible to have the height of the card adjust dynamically. Kind of like a todo list when you add to the list, the card will in create in height

Does anyone know how to hide the ā€œAttributesā€ from the more-info-card? Iā€™ve tried lots of things but canā€™t figure it out unfortunately!

type: custom:stack-in-card
keep:
  outer_padding: true
  border-radius: true
  box_shadow: false
  background: false
  margin: false
cards:
  - type: custom:more-info-card
    entity: light.living_room
    title: ' '
    card_mod:
      style: |
        state-card-content { display: none }
        more-info-light:
          $: |
            ha-attributes {
              display: { display: none }
              ha-select { display: none }
              hr { display: none }
            }
  - type: custom:rgb-light-card
    entity: light.living_room
    justify: around
    size: 35
    label_size: 12
    colors:
      - type: call-service
        service: scene.turn_on
        service_data:
          entity_id: scene.living_room_1_white
        icon_color: '#ffffff'
        label: White
      - type: call-service
        service: scene.turn_on
        service_data:
          entity_id: scene.living_room_2_white_dimmed
        icon_color: '#f1ebdf'
        label: Dimmed
      - type: call-service
        service: scene.turn_on
        service_data:
          entity_id: scene.living_room_3_pink
        icon_color: '#f290f4'
        label: Pink
      - type: call-service
        service: scene.turn_on
        service_data:
          entity_id: scene.living_room_4_orange
        icon_color: '#fcb92e'
        label: Orange
  - type: custom:rgb-light-card
    entity: light.living_room
    justify: around
    size: 35
    label_size: 12
    colors:
      - type: call-service
        service: scene.turn_on
        service_data:
          entity_id: scene.living_room_5_ireland
        icon_color: '#20f32f'
        label: Ireland
      - type: call-service
        service: script.living_room_dynamic_pinkky
        data: null
        icon_color: '#FFB6C1'
        label: Dyn-Pink
      - type: call-service
        service: script.living_room_dynamic_retro_80s
        data: null
        icon_color: '#FAA0A0'
        label: Dyn-Retro
      - type: call-service
        service: script.living_room_dynamic_xbox
        data: null
        icon_color: '#107C10'
        label: Dyn-Xbox

use the custom-more-info card :wink:

1 Like

Fantastic, thank you! :star_struck: Is there any way to hide the ā€œEffectā€ button also?

donā€™t think we added that yet, but open a FR and we can have a look :wink:

1 Like

I have a problem with my current setup. Sometimes the colour is shown and sometimes not. Itā€™s very sporadic and can be fixed by reloading the page in the browser. But on the Android app itā€™s not that easy to reload the pageā€¦


Perhaps itā€™s related to my code and something is wrong with it.

type: entities
title: Temperatur
entities:
  - entity: sensor.temperatur_aussen_2
    type: custom:multiple-entity-row
    icon: mdi:temperature-celsius
    name: AuƟen
    format: precision1
    state_header: Aktuell
    styles:
      font-weight: bold
    entities:
      - entity: sensor.temperatur_tagesminimum
        name: Minimum
        format: precision1
      - entity: sensor.temperatur_tagesmaximum
        name: Maximum
        format: precision1
  - entity: sensor.temperatur_eg_wohnen_taster
    type: custom:multiple-entity-row
    name: Wohnen
    format: precision1
    state_header: Temperatur
    entities:
      - entity: sensor.voc_eg_wohnen
        name: VOC
        format: precision0
      - entity: sensor.co2_eg_wohnen
        name: CO2
        format: precision0
      - entity: sensor.luftfeuchtigkeit_eg_wohnen
        name: Feuchte
        format: precision1
    card_mod:
      style: |
        .entities-row div.entity:nth-child(1) {
          {% set state = states('sensor.voc_eg_wohnen') %}
          {% if state | int < 400  %}
            color: green;
          {% elif (state | int >= 400) and (state | int < 1300) %}
            color: orange ;
          {% elif state | int >= 1300 %}
            color: red ;
          {% endif %}
         }
        .entities-row div.entity:nth-child(2)  {
          {% set state = states('sensor.co2_eg_wohnen') %}
          {% if state | int < 1000 %}
            color: green;
          {% elif (state | int >= 1000) and (state | int < 1400) %}
            color: orange;
          {% elif state | int >= 1400 %}
            color: red;
          {% endif %}
         }
        .entities-row div.entity:nth-child(3)  {
          {% set state = states('sensor.luftfeuchtigkeit_eg_wohnen') %}
          {% if state | int < 40 %}
            color: orange;
          {% elif (state | int >= 40) and (state | int <= 60) %}
            color: green;
          {% elif state | int > 60 %}
            color: orange;
          {% endif %}
         }
        .entities-row div.entity:nth-child(4)  {
          font-weight: bold;
         }
  - entity: sensor.stromzaehler_aktuellerverbrauch_volkszaehler
    name: Stromverbrauch Haus

Iā€™m trying to customize the clock-weather card, but how do I target the clock-weather-card-toray-right-wrap-top field?

I tried doing it this way, but that doesnā€™t work:

        card_mod:
          style:
            clock-weather-card $ ha-card $ div:
              .: |
                clock-weather-card-today-right-wrap-top {
                  display: none;
                }

View of the DOM:

Iā€™m trying to add simple drop-shadow effect globally to all my Home Assistant cards via my custom theme file. For some reason, when I append ha-card { box-shadow: 0px 5px 15px rgba(255,255,255,0.3) !important; } to my card-mode code below, it has no visible effect. However, the other card-mod modifications work just fine.

  card-mod-root: |
    .edit-mode, app-header, app-toolbar {
      background: var(--app-header-background-color) !important;
      color: var(--primary-text-color) !important;
    }
    ha-tabs {
      --paper-tabs-selection-bar-color: var(--primary-color) !important;
    }
    paper-tab[aria-selected=true] {
      color: var(--primary-color) !important;
    }
    ha-card {
      box-shadow: 0px 5px 15px rgba(255,255,255,0.3) !important;
    }

Without testing: This element is not in a shadow root inside ha-card of your card. So you should directly use:

card_mod:
  style: |
    clock-weather-card-today-right-wrap-top {
      display: none !important;
    }

You should address it in the theme-thread.

Youā€™re right, your example worked. But how is it that you can ignore the shadow root thatā€™s under the clock-weather-card element? Iā€™m new to using the card mod and this part is rather confusing.

He answered that questionā€¦

image

Is the below link the theme-thread you suggested? Iā€™m not sure. If not, could you please point me to the right thread? Thanks.