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

All the necessary code is in my post.

Itā€™s a column-spanning card inside a grid-layout card inside a mod-card.

moveup

Help!!! Iā€™m pulling my hair out trying to adjust the spacing and move this text up in the markdown container.

My code is below, what am I doing wrong?!

      - type: vertical-stack
        cards:
          - type: markdown
            content: >
              <h2 style="text-align: center;"> Mark: {{states('person.mark')}}
              </h2> for: {{states('sensor.time') and
              relative_time(strptime(states.sensor.mark_left_home_last.state[:19],'%Y-%m-%d
              %H:%M:%S'))}} <br> Commute: {{states('sensor.waze_travel_time') }}
              mins
            style: |
              ha-card.type-markdown {
                padding-top: 0px;
                text-align: center;
                line-height: 16px;
                height: 110px;
              }

hello, how can i use card-mod to disable the more-info popup when i click on the marker/picture icon inside a map card?? i tried with tap-action function but it doesnā€™t work.

Someone could point me to the right direction??

thanks a lot.

Hi!

Iā€™m using picture-elements card and I run into a problem: I cannot change the icon color of a switch when it is turned on. I tried to use --paper-item-active-color , but it doesnā€™t working.

My code is the following:

          - type: state-icon
            tap_action:
              action: toggle
            entity: light.terasz_szoba_lampa
            style:
              bottom: 33%
              right: 7%
              border-radius: 50%
              "--paper-item-icon-color": black
              "--paper-item-icon-active-color" : yellow
              text-align: center
              background-color: rgba(102, 102, 102, 0.2)

Iā€™d like to have the ā€œswitched onā€ color yellor.

Any ideas? :slight_smile:

Seems like youā€™r using ā€œbasic entityā€ CSS " (which btw should be ā€œstyles:)ā€, and not card-mod ā€¦ but, anyhow, if ' --paper-item-icon-active-color 'ā€™ doesnā€™t work in your Theme, try ā€œtemplateā€ on the ā€œentityā€ ( or " card-mod: style: " ) on the entity

I will answer you in the topic where you posted it first.

It works - but not for light entity in Picture Elements.
Here card-mod seems to be the only solution.

1 Like

i actually just checked my ā€œFloorPlanā€ :slight_smile:

    cards:
      - type: picture-elements
        theme: noctis-grey
        card_mod:
          style: |
            ha-card {
              color: #87BF50; border: solid 2px #A0A2A8; box-shadow: none;
            }
        elements:
          - type: state-icon
            entity: light.d1
            icon: mdi:wall-sconce-flat-outline
            name: light
            style:
              top: 36%
              left: 32%

ā€¦And my ā€œiconsā€ change color , and it seems to be , due to the

Icons

paper-item-icon-color: ā€˜#A0A2A8ā€™
paper-item-icon-active-color: ā€˜#87BF50ā€™

in my Theme

Here is the working solution:

  - type: state-icon
    entity: light.virtual_light_1
    tap_action:
      action: toggle
    style:
      bottom: 73%
      right: 7%
      border-radius: 50%
      background-color: rgba(102, 102, 102, 0.2)
    card_mod:
      style:
        state-badge $: |
          ha-state-icon {
            {% if is_state('light.virtual_light_1','on') %}
            color: red !important;
            {% else %}
            color: cyan;
            {% endif %}
          }

Well, as i said, above works for me ā€¦ but iĀ“ll ā€œkeepā€ your example" if i run into ā€œproblemsā€ another time :slight_smile: (edit: as iā€™ve seen this ā€œstate-badgeā€ before in some post, but didnā€™t thought it was of my concern, as i didnā€™t had ā€œbadgesā€ , but now i realize it must be some new ā€œnamingā€ )ā€¦ thou i donā€™t know whether itā€™s due to the ā€œelements:ā€ tag or what, but my icons changes color cording to Themes, my card-mod is for ā€œborderā€ and text(diff from Theme)
Edit2: Heres is start of my ā€œFloorPlanā€ View

views:
  - title: FloorPlan
    type: custom:horizontal-layout
    theme: noctis-grey
    badges: []
    cards:
      - type: picture-elements
        theme: noctis-grey
        card_mod:
          style: |
            ha-card {
              color: #ffffff; border: solid 2px #A0A2A8; box-shadow: none;
            }
        elements:
          - type: state-icon
            entity: light.d1
            icon: mdi:wall-sconce-flat-outline
            name: light
            style:
              top: 36%
              left: 32%

Check it with the default theme.

Default Theme, when changed under my ā€œprofileā€ only, changes to ā€œdefaultā€ White background/ icon changes blue/yellow ā€¦ if i choose ā€œno themeā€ in the View, and ā€œno themeā€ under ā€œpicture-elementā€, AND even if i clear browser/tried 2 different laptops/browsers ā€¦ i got the colors ā€œassignedā€ from Theme and icons changes color green/grey ā€¦hmmm, where did i ā€œfuā€ or how did i manage it ( im old, and bad memory) ā€¦ thou still somehow ā€œit works for meā€ :slight_smile: ā€¦lol, i let you know if if figure out what iā€™ve done
@Ildar_Gabdullin
PS: iā€™ve tried all (most), removed icon tag(in view config), changed to default icon(on entities) etc. etc. basically im back to all defaults, donā€™t load card-mod, removed the card-mod under picture-element, ā€œrestartedā€ HA /supervisor etc. etc. ā€” still changes from blue>yellow ā€¦ can it be because i use homeassistant os, (a VMw-image) ā€¦ i donā€™t know ā€¦ i canā€™t ā€œremoveā€ the ā€œcolor-changeā€ on/of, even from default-theme/view ā€¦ i do know iā€™ve tried (somewhere) to be able to ā€œseeā€ icon-color change on the tracker-entities( home/away ) ā€¦ maybe iā€™ve fiddled somewhere ā€¦ i give up ā€¦ it works as i want it ( beside i still havenā€™t figure out how i can get the ā€œtracker-entities-iconā€ to change upon state

It is OK. If any problem you find out - you are always welcome to ask here.

1 Like

hi!
thank you for the quick answer.
Something is wrong, when I try this code, not even the original (off state) color changes to cyan.

          - type: state-icon
            entity: light.terasz_szoba_lampa
            tap_action:
              action: toggle
            style:
              bottom: 73%
              right: 7%
              border-radius: 50%
              background-color: rgba(102, 102, 102, 0.2)
            card_mod:
              style:
                state-badge $: |
                  ha-state-icon {
                    {% if is_state('light.terasz_szoba_lampa','on') %}
                    color: red !important;
                    {% else %}
                    color: cyan;
                    {% endif %}
                  }

what do I do wrong? :slight_smile:

Here is a diff between your code & my code (with trimmed spaces):


I do not know why it does not work in your setup.
Do other card-mod examples work?

Uhh, the problem was withc card-modā€¦ cool, it works now - almost :slight_smile:
for some reason the color display different (darker) as on other icons (state-icon / switch, coloring works perfect without card-mod):

image

Is there a way to style the icons on the tab headers? I would like to change those from outline to filled versions if the room it represents is active (or similar).

Search in card-mod themes thread.

1 Like

Most probably, there is a filter or a transparent or alpha set as well, which you should adjust according to your needs.

See above

How to enable / disable a ā€œfold / unfoldā€ control for fold-entity-row

image

image


More card-mod examples

Why the ā€œmod-cardā€ is here?
190 lines for MWE - and zero appearances of ā€œcard-modā€ keyword.

1 Like