Custom padding for button symbol with / without icon

Hi, I’m using the new stacking functionality for Symbols and wondering how I can achieve the following layout for a button with an optional icon:

As you can see, the left padding before the icon is only 8px, while right padding is 12px. Gutter between icon and label is 6px.

This means that if I hide the icon, the left padding stays at 8px and looks off:

I’ve found a temporary solution which is to add a single space before the label but it’s kind of jank

Anything else I’m missing that would make this cleaner? Or should I abandon the idea and make two symbols, one for icon+text button and one for text button?

Yes, I think your best case is to use two separate button symbols here. I can see why you’re using separate padding with the left and right edges

1 Like

Thank you!

Since I’m working with these new features, can I also ask if it’s possible to replace layer style of the main frame?

I see that for Button M, Solid there is no longer any background rectangle, so there is no way to specify an Override, right?

The only way I can do this is to paste back the rectangle, ignore stack layout and stretch it back to 100% of the available space. Then I can switch button’s background layer style to hover or pressed (for example).

Yes! Frames now support layer styles in the new version. We did this so you don’t need to hack around with a rectangle and ignore layout. Took a screenshot of a selected instance where you can see the layer style you can swap there.

3 Likes

Oooooh now it makes sense, thank you! I wonder what I was missing… when I made symbol from that frame, I was surprised that while background rect’s styles were copied as-is, the layer style wasn’t copied (was empty). Now I fixed it and I can override! Awesome stuff, this is the best update maybe ever.

3 Likes