Hi Figmanauts, quick question in case anyone has seen a cool workaround.
I’d like to see if there is a clever way to make a bunch of components that share a parent element automatically all be the same size.
I can’t set them to “fill” because I want the size of the parent element to be determined by the width of the largest child element (ie: the parent element is set to Hug).
I don’t want to set the child elements to “fixed” because I want the design to be flexible, and be based on the width of the text inside each button.
Manually what I’d do is I’d look at the collection of child elements, choose the one with the longest text and set it to Hug, and then set all the others to Fill. That will meet my requirements, except…. if the text changes, then the “widest” element may be a different element and then I have to go and switch which one has Hug and which one has Fill.
Here’s an example:
Imagine an autolayout frame containing a number of elements. The autolayout frame is set to Hug so it is as wide as the widest element inside it. Each element inside it is an instance of the same component, say, a button. These buttons also have autolayout so that they grow or shrink depending on the text label inside the button. In this case, all the buttons will be different widths, depending on their text size and the “parent” frame will be as wide as the widest button.
Now, is there a way to make all the buttons inside this frame the same width, choosing the widest one (based on the text inside it) as the width for all of them? And if you change the text in the buttons, have them figure out which is the widest and then adjust the width of all the others accordingly?
As I write this, I’m pretty sure there is nothing other than my “manual method”, since Figma doesn’t adopt CSS Flexbox. But maybe there’s a funky workaround?