button-card: HA 2025.0 custom_fields not working anymore

After the upgrade to HA 2025.0 the Button Card the custom_fields: are not styling anymore:

name: Oven
icon: mdi:toaster-oven
color_type: card
show_state: true
show_entity_picture: true
custom_fields:
  Percentage:
    card:
      type: custom:button-card
      entity: sensor.oven_programma_voortgang
      tap_action:
        action: none
      show_name: false
      show_state: true
      show_icon: false
      show_entity_picture: false
      color_type: card
      color: rgba(255,255,255,0.8)
      card_mod:
        class: card-custom-field-info
card_mod:
  style: |
    ha-card:hover {
      {% if( is_state('switch.oven_inschakelen', 'on') ) %}
        box-shadow: var(--my-custom-button-card-hover-on) !important;
      {% else %}
        box-shadow: var(--my-custom-button-card-hover-off) !important;
      {% endif %};
    }
styles:
  card:
    - width: 155px
    - height: 155px
    - margin: "-185px 5px 5px 13px"
  name:
    - display: block
    - position: absolute
    - left: 8px
    - bottom: 21px
    - font-weight: bold
    - font-size: 16px
    - font-family: Sans-serif
  img_cell:
    - margin: 0px
    - padding: 0px
  state:
    - display: block
    - position: absolute
    - bottom: 5px
    - left: 12px
    - font-size: 14px
    - font-family: Sans-serif
    - text-transform: capitalize
  icon:
    - width: 100px
    - margin: 0px 0px 5px 0px
  custom_fields:
    Percentage:
      - width: 50px
      - display: block
      - position: absolute
      - top: 8px
      - right: 8px
      - font-size: 14px
      - font-family: Sans-serif
      - text-transform: capitalize
      - overflow: hidden

color and fonts are not applying anymore:

field

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

This means someday, the other “styles” in button_card will also not work anymore.

Except that it’s not true at all… I don’t understand why people use card_mod together with button-card… When button-card has so many options, including js etc… By the way, read the documentation of the extra_styles section.

Check my config, you can edit all css changes via extra_styles. When you create templates for it, for each button custom_fields has its own div id, then you can customize it specifically for a particular element.

https://github.com/ngocjohn/hass-config/blob/main/config/dashboards/templates/button_card_templates/tpl_base.yaml#L196-L1171

Than we use card_mod for the values that do not work anymore in the style from button_card

Because you have been using it wrong from the beginning. For styles, manimuplate with ha-card contaier in styles card…

styles:
 card:
  - background: etc..
  - --ha-card-background-color: red # simple change HA css vars.. 

Or via the extra_styles I mentioned above.

extra_styles:
  return `
    #card {
      background: red;
    }

button-card can work alone, without card-mod… 👍

Here’s how each button-card looks like… button-card is a custom component itself, it has its own shadow root. then it has a ha-card component with id #card, in it is the main #container, where it contains your yaml code for the cards. Through the main #card or ha-card you can modify the styles for every other childs element… Don’t be surprised if the card is long without updates or releases. Because there is nothing to improve. Stop blaming bugs for everything, because of your own incompetence.

CleanShot 2025-01-10 at 12 24 57@2x

Thank you! I will try to, but as far as I see I am indeed not capable to do this. html/ccs was 15 years ago for me.

I did copy the example from custom_fields

That dit not work for me anymore. I will try to do it with extra_styles or from your example.

well, what can we tell you.

Scherm­afbeelding 2025-01-10 om 14 42 57

all working just fine