Possible to evenly space multiple buttons to each other? #53
-
I have a few few buttons of varying widths, so they don't appear centered overall. Here's an example of a card along with the same card broken into a horizontal stack. You can see the plain paper-buttons card isn't evenly spaced/centered. Downsides of using a horizontal stack are the borders as well as the fact that Let me know if I'm missing a way to do this, but some sort of "button spacing" option would be great to have. Here's the config for the top card:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Good question, so the best way to do this is by using type: entities
title: Internet
state_color: true
entities:
- type: custom:paper-buttons-row
base_config:
style:
button:
margin-bottom: 8px
margin-left: 4px
margin-right: 4px
width: 100%
# other aesthetic styling options
background-color: var(--table-row-background-color)
border: 1px solid
border-color: '#FFFFFF'
border-radius: 4px
justify-content: center
buttons:
- icon: mdi:router-wireless
name: ROUTER
tap_action:
action: call-service
service: shell_command.reboot_router
- icon: mdi:lan
name: WAN
tap_action:
action: call-service
service: shell_command.restart_wan
- icon: mdi:wifi
name: WLAN
tap_action:
action: call-service
service: shell_command.restart_wlan |
Beta Was this translation helpful? Give feedback.
-
I have a follow-up question around this topic. I have a "box" with 21 paper buttons, where I have 3 on each row. When I did set this up, I defined style and state_style on each single button, and it's a pita to change. So this is a great way of doing it much easier. However, I have one issue now when I did it on top. This is my code (for some reason, when I use insert code with the option, it just shows as a table, so this was the easiest way to show it with formatting): It now shows the buttons correctly and evenly spaced, and it takes the "global" config when it comes to spacing, radius etc. However, I did have a state_styles to keep the name white instead of the normal blue, and no matter how I add it to the base_config, it does not seem to stick. It's not in the code over as I couldn't get it to work, but the second row here is how I would like to have it look, while the first row is how it does look when it's not defined in base_config anywhere. Now the last question is this, I use as vertical stack and then putting 21 paper buttons in it, and it means for every 3rd button, I have to defined a new -type: custom:paper-buttons-row. When I do, the base_config just works for the first (which makes sense). Is there a way to make this easier, or is there a way to drop vertical stack and do several lines of paper-buttons instead? Sorry if this should be obvious, it's a learning process :) |
Beta Was this translation helpful? Give feedback.
Good question, so the best way to do this is by using
width: 100%
andmargin
, basically, you set each button to have a width of 100% and then use margins to control the spacing between them. Here's an example