r/FigmaDesign • u/_Prateek_Hota_ • Oct 03 '26
help Help me with irregularities in width!
I have two buttons inside an auto layout frame. Their widths are set to fill to ensure equal width distribution. But somehow the left button is taking up 2px extra. I have excluded the stroke value to add up but it still gets added up to the width and the stroke position is also 'Inside'. Once I remove the stroke, both buttons fill up the space equally. How to prevent this from happening?
One solution I found was to give the right button the same stroke value as the left one. But is it the best possible way to deal with it? I don't wanna introduce another variable into the button.
Edit: I got to know that Figma introduced this behavior to match CSS behavior. https://help.figma.com/hc/en-us/articles/42031586813719-Use-auto-layout-with-CSS-Flexbox-in-mind
10
u/_KBDMC Product Designer Oct 03 '26
A quick fix, give the button on the left a transparent border the same width as the one on the right
13
u/qazwsx444444 Oct 03 '26
Yep they changed that recently motherhuggers citing that it works more closely how it work in CSS.
2
u/chernoholik Oct 04 '26
If you have tokens for padding, you need to split them up into two categories: 1. normal padding; 2. Inline padding
The normal padding variables are used for containers/frames where there isn’t a border/stroke. The inline padding accounts for the border/stroke.
Let’s say you have a filled primary button with padding 24px left and right. If you want a ghost button you need to use inline padding which is easily calculated like so: normal padding - border/stroke width = inline padding. (24-1=23)
If you want to simplify it - use a border/stroke on all buttons. For the primary button you can use the token for the fill colour.
2
u/bink-1567 Oct 05 '26
ok so you went with grid and fr units, did that still hold up when one button label gets way longer than the other? like in a translated version or something. i always worried grid would just squish teh longer label and truncate it instead of letting it wrap
2
u/ResistDull7601 Oct 03 '26
I know it’s off topic, but ux tip: try primary button fill, and secondary hug
4
u/testingaurora Oct 03 '26
Yes this works like css box layout. Just add a stroke to the smaller one
1
u/rock_x_joe Oct 03 '26
You could switch back to the old auto layout model in the auto layout settings menu you had open (last option)