Smart layout - symbols not expanding to fill container

I’ve got a button Symbol, which is using horizontal smart-layout, so that the button width is set by the button label text override.

I wish to stack 3 of these buttons, and have the width of all buttons to be the same as the longest button.

I’ve created a new symbol using horizontal layout, and added 3 buttons. The buttons have pin to edge left+right.

When I override text on a button in an instance of the symbol, that one button expands, and so does the symbol container - but the other two buttons do not expand to fill. (i.e. not respecting the pin to edge)


If I detach the button instances from their symbol, the behaviour works as expected:


Obviously this is not ideal, I’d rather use the buttons as symbols.

What am I doing wrong and how can I fix this?

Hi Meza, I want to share a solution I think can help you with this component.

The key is to use the min-width setting. This will allow all buttons to resize to the minimum size you set. The buttons will still resize beyond that if you enter more text, but this can be quite useful to keep all symbols the same size.

First, create a base symbol and set a min-width value

When you first add the button it will be of the same size as the source, but when you override it, it will take the min-width value

Note: the left and right pinnings on the button’s text or background are not needed here. You may want to add fixed size to the icon to handle manual resizing though.

Next, create your button menu

Add the instances you need for your button menu. You can add vertical Smart Layout for hiding and showing items as needed.

When you add an instance of the menu, it will have the min width value:

Bonus: you can manually resize if needed
You can manually resize your button menu if needed and the only extra settings you need is to add fixed size to the icon, so the shape is kept when manually resizing

Here’s a sample file, I hope it’s useful
min-width-symbols.sketch (214.4 KB)

1 Like