Skip to main content
Johan_Dahl
Feb 9, 2021 7:28 AM UTC
Question

Can I distribute leftover space evenly when using auto-layout?

I’m trying to do a tab-component, that would work just like flexbox does.

Tabs should stretch to fill the available space. The tabs should not all be equally sized but sized according to their intrinsic width, and the left over space should be distributed between them.

You can see my image here, can I do this?

This topic has been closed for replies.

5 replies

ntfromchicago
New Participant
Feb 10, 2021 4:54 AM UTC

For this use case, are you wanting the purple line to go all the way across? Or just for the active tab? And if just the active tab, does it stop just after the ends of the text, or do you want to extend the line longer to fill up 50% of the empty space to the left and right?

Johan_Dahl
Feb 10, 2021 7:44 AM UTC

I added more images to hopefully make it more clear what I’m after.

I want the tabs to span the full width of the container element without the tabs to be forced into equal width. That is, they should each take up their intrinsic width (which is different because the text is different) and then they should divide the remaining space between them so that they fill the container.

This is how I want it to behave.
Screenshot 2021-02-10 at 08.38.40

This is how it behaves.
Screenshot 2021-02-10 at 08.43.16

tank666
Feb 10, 2021 4:07 PM UTC

You can see my file: Figma
Is this what you need?

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
May 21, 2024 8:31 AM UTC

Hi Johan, currently struggling with the same problem. How did you solve this for you?

Johan_Dahl1
May 21, 2024 8:46 AM UTC

Hi Leon.

This was some time ago so I don’t remember that clear but I never solved it in any beautiful way. I think I had to make my component more static to “solve” this problem. However, I haven’t used Figma for a while now so there might be some new solution that I’m not aware of now.