đŸ”č Card-mod - Add css styles to any lovelace card

This is not a custom card. Instead it’s a plugin which changes the way all other cards work

How about this?

type: entities
style: |
  ha-card {
    color: red;
  }
entities:
  - light.bed_light
  - light.ceiling_lights
  - light.kitchen_lights

51
Not a custom: in sight.

Or this?


(Please click this gif to open it. It seems to be prone to artifacting when compressed)

Or how about changing what happens when you click the name or icon in an entities-card?


FANTASTIC POST BY ILDAR GABDULLIN ON HOW TO MODIFY EVERYTHING WITH CARD-MOD


45 Likes
Floorplan full size card
Column width/Card length
State based styling in picture-elements
Lovelace: Simple Xiaomi Vacuum Card
HACS question about adding repositories
Card-mod font size
Styling elements in Picture elements card: a small tutorial
Creating Table in markdown card
Change icon color on Condition
Sensor state changes text color on View
How to format the text in the new Heading cards?
Sidebar - Fixed Width
Card-Mod - Heading Card
Change icon colors in a glance card
Mushroom Cards - Build a beautiful dashboard easily 🍄 (Part 1)
Lovelace: Flexible Horseshoe Card (Donut graph, flexible layout, multiple entities, actions & animations), including next-gen experimental examples
Custom Card Mod - Change Icon & Colour on State
Icon Colors - range of power consumption
Card: individual Background Color
Lovelace UI HTML
Entities card with lock confirmation text and colored icon problem
Badges attributes
đŸ”č Card-mod - Super-charge your themes!
Another 'Icon color change based on state' question
Custom Card in More-Info
Stack-In-Card: Drop-in replacement for vertical-stack-in-card
Change colour in secondary-info entity card [multiple-entity-row]
Adding css to UI card
Markdown card width
Lovelace: mini graph card
Change size of Picture card
How to combine different card mods in same card?
Noctis Theme
Weather forecast today
State badges styling/animation stopped working
Changing text colour based on value
Change icon style and text color in mushroom template card
Change Dashboard Card icon color
Picture Element - State Badge Label removal
Reduce Card Header Size
Card-mod --ha-icon-color: 'red' not working
Text change colour on the value of input
Can I use the same card_mod multiple times?
Light Entity Card
đŸ”č Layout-card - Take control of where your cards end up
3D Floorplan with Hue & Saturation mapped to individual, blended RGB Light Entities
Lovelace: Advanced calendar card
Lovelace: Mini Media Player
Color of switch without feedback
Colorize sensor value when >= 70
Custom CSS in Home Assistant?!
Changing sidebar title and favicon
Custom Card Mod
Lovelace: Bar Card
HA UI > Sidebar > Scrollbar
Text color based on sensor values
Samsung Family Hub Refrigerator
MeteoAlarm info card
Style whole entities card based on state of entity within
Themes and tag HTML
Dynamic badge label (text) colours
Power Distribution card
Lovelace input_select without an icon?
Broken configuration after core 2024.6.0
Change icon colour with card-mod for cover
Lovelace Entity Card Name Text Position
Broadlink RM4 PRO in home assistant
Add buttons for predefined brightness to entities card
Global Mod - Add custom styles to any frontend Home Assistant element
Borders when using card-in-card
Margin-right custom:slider-entity-row
Parking lots (garages) in Ghent. Can someone help to develop?
Dashboard entitity icon from sensor value
Glance card spacing
Person Cards - Show Off Yours
Show state value in picture-glance card
No square picture in glance card
Dashboard button icons color
Use of the statistics-graph map - Color of the graph
Change color of (input_number-) slider?
Button with state of other entity (colour)
Badge icon colour to reflect the state of a binary sensor
Card_mod background images based on sun.sun
Card mod. Change colour of Secondary Text based on last updated
Icon colour change depends on value of thermometer or Battery
Change colors for gauge card?
Picture-elements card state-icon: trying to make a mdi:fan rotate on its axis, but can't be centered
Installation card mod
Picture-entity: change mdi icons based on state, what is the working method?
Is it possible to disable the more info pop up in lovelace ui?
Smaller Statistics Cards... is it possible?
How to add colour to a boring entities card configuration
Card-mod not working
Cant change the height of a card, only width works
Customization of Title for "state-badge" within "Picture Element Card"(edited)
đŸ”č fold-entity-row - Hide away stuff in entities cards
Debugging why card-mod isn't working
WTH are badges only on top?
Color part of a number
Sports Standings and Scores
Modifying font and icon size in Heading Card
How to customize the badges at the top of the page?
WTH: line colours in history
History-graph scaling
Dropdown in picture-elements
Card-mod icon animation in badges
Trouble with Circle Color Based on Status
Customizing a Lovelace Card
Custom:fold-entity-row without entity icon
đŸ”č Card-mod - Super-charge your themes!
Mushroom Cards - Build a beautiful dashboard easily 🍄 (Part 1)
Replace String in Stack Card
Templating the icon of a cover device class via customize
Mushroom Cards - Build a beautiful dashboard easily 🍄 (Part 2)
Tile card but just dropdown
đŸ”č Card-mod - Super-charge your themes!
How do I style all entity popups using card-mod-more-info in the theme?
Lovelace: Mini Media Player
Transparency
Alter font size of entity card "state" only (not font size of entity name)
Terminology for Noob with years of programming experience
đŸ”č Browser_mod - turn your browser into a controllable device, and a media_player
2025.11: Pick, automate, and a slice of pie đŸ„§
A problem with a display that the system is not in the English language
Open spaces between cards in Dwains Dasboard
đŸ”č Card-mod - Super-charge your themes!
đŸ”č Card-mod - Super-charge your themes!
First card on first dashboard won't stay transparent (card_mod)
Hide an icon and a title in the tile card
Show off your picture-elements uses
Custom Border On Mushroom Chips
đŸ”č Card-mod - Super-charge your themes!
Customize css on section
How do I get an entity's value to change icon colour with an IF statement?
Lovelace: Bar Card
đŸ”č Card-mod - Super-charge your themes!
In card, access label attached to entity - custom button-card and card-mod
Struggles understanding card-mod 3
Need help with style / card mod
Moving horizontal panels
Styling elements in Picture elements card: a small tutorial
đŸ”č Auto-entities - Automatically fill cards with entities
Alarm status as very clear message
Help with code pleae
How to represent an input_number with state dependent icon And color
Card Mod: Hide header of entity-card
Samsung EcoBubble - Display energy by month and current state in "one" card
Customized cards for data from the "FeelFit integration"
đŸ”č Card-mod - Super-charge your themes!
đŸ”č Auto-entities - Automatically fill cards with entities
Badges in footer instead of header
Lovelace: mini graph card
đŸ”č Auto-entities - Automatically fill cards with entities
Lovelace: mini graph card
Power Distribution card
Creating a custom dashboard, whats the best way?
Help required combining some card-mod code on a Tile card
đŸ”č Card-mod - Super-charge your themes!
Terminology for Noob with years of programming experience
What has changed in 2026.4.x regarding card_mod?
Lovelace: Simple thermostat card
How to create an input control to lovelace UI?
đŸ”č Auto-entities - Automatically fill cards with entities
How to color the icons of a sensor, device class “enum”
Add another entities state to Tile Card - card_mod problem
Card mod remove icon background
HA UI > Sidebar > Scrollbar
Image blink animation when entity state changes
Styling elements in Picture elements card: a small tutorial
đŸ”č Layout-card - Take control of where your cards end up
How do I get an entity's value to change icon colour with an IF statement?
Change name or friendly name based on sensor value
đŸ”č Auto-entities - Automatically fill cards with entities
Dynamic badge label (text) colours
Help with bigger icons and date from year month day to day month year
đŸ”č Card-mod - Super-charge your themes!
Card-mod to change dashboard background
ApexCharts card - A highly customizable graph card
đŸ”č Card-mod - Super-charge your themes!
Clipping text with large font size set
Card-mod usage in vertical-stack-in-card
Can I stop all interactions within an iframe, making it "view only"?
Media player card scale
Touchy - Touch friendly media player card (combination of cards)
How to change text in a custom:text-divider-row
How to change text in a custom:text-divider-row
How to display SVG Files in Picture Elements
Auto-Entities + Card-Mod: Hide entity state
How can I recreate a graph like this?
Card_mod settings stopped working on Thermostat card after 2024.8 update
Have Entity Card User Sensor Value as Part of Title
How to template a simple button with a "confirmation" value

@thomasloven nice stuff, does this plugin deprecate: https://github.com/thomasloven/lovelace-card-modder ?

Yes it does. To 95% or so


1 Like

I’ll begin converting my lovelace over to using the new module.

1 Like

What are your plans for card-modder going forward? I use card-modder against a lot of other cards, mostly custom: cards, and would hate to lose that functionality, especially considering that the changes I make via card-modder are typically one off mods and not global changes for all cards.

1 Like

Trying to switch to the new card like this:

              - type: 'custom:text-divider-row'
                style: |
                  ha-card {
                    --secondary-text-color: var(--primary-text-color);
                  }
                text: Blah
              - type: 'custom:card-modder'
                style:
                  --secondary-text-color: 'var(--primary-text-color)'
                card:
                  type: 'custom:text-divider-row'
                  text: Household

image

But it does not modify the colour of the card correctly. I want both to use a white line and colour of text. The card is locked to secondary-text-color but I want it to change to primary-text-color. What am I missing? (Also tried the var(–primary-text-color) in ‘’ as well)

1 Like

text-divider-row isn’t a card, it’s an entity row, so it’s meant to be used inside an entities card.
You can style that card to be invisible, and change the text color:

type: entities
style: |
  ha-card {
    background: none;
    box-shadow: none;
    --secondary-text-color: var(--primary-text-color);
  }
entities:
  - type: custom:text-divider-row
    text: Blah
3 Likes

The styles are applied on a card-by-card basis. It’s only the ability to style that is added to all card globaly.

There are some functions of card-modder which aren’t available in card-mod, e.g. styling things that doesn’t contain a ha-card element. Until I have a solution for all of those (that I can think of) card-modder will still be available. But it absolutely recommend using card-mod instead.

And it will work with any custom-card that contains a ha-card element.

1 Like

Per your usual, Thomas. Great!

Can you template in the style?

1 Like

Of course. As detailed in the readme.

A quick question, i saw the following in your example

type: entity-button
entity: light.bed_light
style: |
ha-card {
background: [[ if(light.bed_light == “on”, “green”, “”) ]];
}

Can I also make an else if ? I try to get the following working, but it won’t. What did i miss ?

style: |
  @keyframes blink {
    50% {
      background: [[ if(states.binary_sensor.meteoalarm.attributes.severity == "Moderate", "yellow", "") else if (states.binary_sensor.meteoalarm.attributes.severity == "High", "red", "")]];
    }
  }
  ha-card {
    animation: blink 10s linear infinite;
  }
1 Like

Thanks
 that worked
 but I really don’t understand why it worked before if it’s not a card? I get that it doesn’t have a ha-card element and that’s why it doesn’t work but you can add that ‘card’ text-divider-row anywhere
 I only wrapped it in card-modder because I wanted to change the colour
 So thanks for the fix but I don’t understand.

Card-mod works only with ha-card. Card-modder works with other things too. That’s all.

From the wiki post linked from the documentation:

<then> and <else> can be any template - including further if() -expressions"

Kind of got this working. I have an entity card with 2 enitities. I want to colour the icon based on state. This works but the second entity only changes colour if the 1st one has changed colour.
Probably because I have no idea how to use the #states part. Also, if I remove the background part, the rest doesn’t work
Any ideas ?

type: entities
title: Front Door Lock
show_header_toggle: false
style: |
    ha-card {
      background: var(--background-card-color);
    }
    #states div:nth-of-type(1) {
      --paper-item-icon-color: [[ if(lock.assa_abloy_yale_conexis_l1_sd_l1000_ch_locked == "unlocked", "red", "green";
    }
    #states div:nth-of-type(2) {
      --paper-item-icon-color: [[ if(sensor.front_door_lock_battery <25, "red", "green";
    }
entities:
  - entity: lock.assa_abloy_yale_conexis_l1_sd_l1000_ch_locked
  - entity: sensor.front_door_lock_battery
1 Like

You need to end the if(s with a ) and the [[s with ]].

Trying to figure out how to apply this to slider-entity row’s label so that it wraps instead of ellipsing on overflow. Ultimately I want to unset “text-overflow” and “white-space” on the “div.info” element
 The jquery selector path is as follows
 just can’t figure out what this is supposed to translate to for card-mod:

$(‘home-assistant’).shadowRoot.querySelector(‘home-assistant-main’).shadowRoot.querySelector(‘ha-panel-lovelace’).shadowRoot.querySelector(‘hui-root’).shadowRoot.querySelector(‘hui-view’).shadowRoot.querySelector(‘hui-entities-card’).shadowRoot.querySelector(‘slider-entity-row’).shadowRoot.querySelector(‘hui-generic-entity-row’).shadowRoot.querySelector(‘div .info’)

1 Like
style:
  # The following two lines are separated to make sure card-mod first goes into _every_ div inside #states, and then looks for slider-entity-row inside each of them
  "#states div":
    slider-entity-row:
      $:
        hui-generic-entity-row:
          # Once we reach the final shadow-root in our path, there's no need to drill any deeper
          $: |
            .flex .info {
              text-overflow: unset;
              white-space: unset
            }  

Unfortunately, due to how lovelace loads custom elements this won’t be applied immediately, but will happen after the first state update.
I’m still looking for a way to fix that


6 Likes

Thanks for the reply, don’t know how the brackets were missing !

All working fine now, great mod, thanks

1 Like

Thanks!. This worked as expected and was super helpful in connecting up your syntax with the console query.