Howdy there everyone. I have a button that has an icon on the left and text to the right of it. The icon + text group should always be centered within the button no matter how long the text is.
This works fine for a normal button using horizontal layout. However, for this particular button I want to be able to stretch it’s width to take up the full width of the artboard, but also keep the icon and text centered.
It doesn’t seem to work with any group + layout + pinning combo I’ve tried, so I wanted to see if anyone has figured out a solution?
Would you mind sharing a Document with your Component (it can be just it!) so we can take a look?
This is possible with Smart Layout, but with some caveats:
If you manually stretch (or expand) the button, and you decide to change the Override (Text), then Smart Layout will kick-in and resize the button to fit its contents. This means that if the button’s width was wider than the result of Smart Layout it will shrink it.
Pinning and Resizing options work so elements in the Canvas, react to their “parent”. So whenever you resize an Artboard (or even a Group) that have these options enabled, they will act accordingly and keep their edges pinned to whatever options you have set.
In any case, we’d really like to take a shot at this and see if we can help!
I got it! @dfmedrano your sketch file wasn’t quite what I was trying to do, but I modified it slightly and it actually did what I needed. So I applied the changes to my file and it works now. Thanks!
So, the end goal was that I wanted to put instances of these buttons into another symbol, and the buttons would always stretch to be 100% of the width of the artboard. That was all fine if they were placed in an artboard, but when they were nested in another symbol, then overriding the text would kick in the smart layout resizing.