Like this:
styles:
icon:
- color: var(--button-card-light-color)
Like this:
styles:
icon:
- color: var(--button-card-light-color)
Thanks for getting back to me. Iāve added it in but doesnāt seem to have changed it other than set it to a light blue. Here is the full code iām using:
aspect_ratio: 3/1
color_type: card
entity: light.33128450807d3a7697e2
icon: 'mdi:heart'
lock:
enabled: true
name: Chloes
state:
- value: 'on'
styles:
state:
- color: 'rgba(255, 255, 255, 0.4)'
icon:
- color: var(--button-card-light-color)
card:
- background: 'rgba(7, 17, 51, 1)'
- border: 'solid 2px rgba(222,211,13,0.4)'
styles:
card:
- font-size: 80%
type: 'custom:button-card'
Iām still looking for a fix or way around for my long automation names.
If i could find a way to have 2 lines for itā¦ (cant find it on google) or maybe another workaround, feel free to helpā¦
I tried shorteningā¦ but thats hard for automationsā¦ For ex āNachtlampje Noorā doesnt fit the button (1 line)
try
styles:
name:
- max-height: 2.4em
I dont see difference with that, it still is 1 line
thx for trying
you have to combine it with whatever you did here:
Bingo !!!
But a new problem rised.
Its not aligned left anymore, although first it was. + the icon moves if theres only one line
My code now:
button_card_templates:
automation:
show_label: true
show_state: true
size: 30%
color_type: card
styles:
card:
- font-size: 14px
- height: 120px
- width: 120px
img_cell:
- justify-content: start
- align-items: start
- padding-left: 20px
name:
- white-space: normal
- max-height: 2.4em
- justify-self: start
- padding-left: 10px
- font-weight: bold
state:
- justify-self: start
- padding-left: 10px
state:
- value: 'on'
styles:
state:
- color: 'rgba(0, 0, 0, 1)'
icon:
- color: 'rgb(255,140,0)'
card:
- background: 'rgb(255,255,255)'
name:
- color: 'rgba(0, 0, 0, 1)'
- value: 'off'
styles:
state:
- color: 'rgba(255, 255, 255, 0.4)'
icon:
- color: 'rgba(255, 255, 255, 1)'
name:
- color: 'rgba(255, 255, 255, 0.7)'
As you can see, im using template now, so i dont need to repeat it for every automation
text-align: 'left'
Works thx, and for the icon?
So i doesnt jump down one lineā¦ see picture above
Youāll have to make the img_cell size static. possibly set it to a static height.
i tried with
styles:
img_cell:
- height: 20px
but then the icon just gets smaller, it doesnt move up
add
grid:
- grid-template-areas: '"i" "n" "s"'
- grid-template-rows: min-content auto min-content
to styles
ok that fixes the icon, but now the text underneath isnt good anymore
theres now a line between the name and the stateā¦
Also when 1 line it should be the first above the stateā¦ now its centered between the two
Sorry mate
use align-self: end
in the name style.
Ur brilliant mate,
Almost perfect, now if i could lower the icon a little bit more down, its perfect (cause with the grid it went up)
play with the % size. If thatās the size you like, then youāll have to play with the values in the grid-template-rows. Something like 1fr 1fr min-content
I suggest you use the documentation and read up on the grid section because there is literally endless solutions.
ok i will
Thx for your help mate.
I find that grid stuff the hardest part of the whole card
EDIT: Got it final ! Thx @petro !! Appreciated !
I know there have been some changes lately and I feel like I have missed something.
I have a Button Card embedded in a Decluttering Card template. I use it to select the master speaker for my Sonos system. Tapping the card sets an input_select
to the proper speaker entity. Previously, one of the 5 buttons was always ālitā when I entered the view. Now, when I enter the view, no buttons are ālitā and I have to tap a button to change the input_select
state before anything is ālitā.
Tl,dr Previously, the buttons always indicated the current state of the input_select
. Now, I have to change the state for the buttons to recognize it.
sonos_master:
card:
entity: input_select.sonos_master
name: '[[name]]'
state:
- color: var(--primary-color)
value: '[[value]]'
tap_action:
action: call-service
service: input_select.select_option
service_data:
entity_id: input_select.sonos_master
option: '[[value]]'
template: input_button_thick_name
triggers_update: all
type: custom:button-card
No need for that.
Did you try without the decluttering-card to see what happens ? Also did you update to the latest version of both button-card and decluttering-card?
I did try without the decluttering-card and the behavior is the same. The input_select
is set to āmedia_player.sonos_living_roomā. When I go to my view with these cards, the āLiving Roomā button goes āonā and then back āoffā. I have to click one of the other buttons to change the input and then click on āLivingā Room" again to get it to turn āonā.
I had already removed the triggers_update: all
. That was left over from troubleshooting.