Set an icon and icon background like in Tiles card #1012
Mariusthvdb
started this conversation in
Ideas
Replies: 2 comments 6 replies
|
When icon is round this is pretty easy as you say. Below example with ripple adjusted to match icon background. type: custom:button-card
entity: light.kitchen_lights
section_mode: true
grid_options:
rows: 3
columns: 6
tap_action:
action: toggle
icon_tap_action:
action: toggle
styles:
card:
- "--button-card-ripple-hover-opacity": 0.04
- "--button-card-ripple-icon-hover-opacity": 0.5
- "--button-card-ripple-icon-inset-padding": 0
- "--button-card-ripple-icon-border-radius": 9999px
icon:
- background: rgba(from var(--button-card-light-color) r g b/0.2)
- border-radius: 9999pxHowever when the icon/image does not have 1:1 aspect ratio, this is where pill style does not really work well. This is why button-hard default ripple is not a pill but a rounded square as this looks best in majority of cases for a default. This is an example of using 12px border radius for background and ripple on a 'tall' PNG type: custom:button-card
entity: light.kitchen_lights
section_mode: true
grid_options:
rows: 3
columns: 6
icon: mdi:access-point-minus
show_entity_picture: true
entity_picture: /local/media/height.png
hold_action:
action: toggle
icon_tap_action:
action: toggle
styles:
card:
- "--button-card-ripple-hover-opacity": 0.04
- "--button-card-ripple-icon-hover-opacity": 0.5
- "--button-card-ripple-icon-inset-padding": 0
- "--button-card-ripple-icon-border-radius": 12px
icon:
- background: rgba(from var(--button-card-light-color) r g b/0.2)
- border-radius: 12pxScreen.Recording.2025-10-07.at.11.52.36.am.mov |
6 replies
|
Hi. Maybe I'm too late (I just stumbled across this now) or I didn't understand the problem correctly, but I'd still like to show you my solution. I implemented it using img_cell (apologies for the German names and terms): |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
getting used to the core Tile card and its use of icons, I like to create a template for the same styling in
custom:button-cardit is less than obvious, as the elements aren't the same (eg .container vs image-cell and others) and the icon background in button-card currently is not set by default at all so it seems.
there is this in the Frontend repo in core for the tile card icon/icon-background: https://github.com/home-assistant/frontend/blob/a6d3041d599d02042e8857d06ec932933e1ea1dd/src/components/tile/ha-tile-icon.ts
which is rather a lot to translate to button-card 's icon and its background
maybe we can build it here together?
because, to give a simplest of issues:
which works in the UI editor
is made more difficult in a more complex card....
and makes it immediately clear we need to set the size of both elements....
that is only about the icon in regular state, and not even talking about tall the other styles, like hover ripple ea..
All reactions