Icon, Text, and smart layout

For some reason, I can’t seem to figure out how to create this simple card with smart layout. All I want to do is enter in text and have the icon center align in the container with the text. Simple, but it’s not working. Any suggestions?

Hi Derek,

That certainly is possible!
Firstly, make sure you haven’t pinned the icon to the top and/or bottom (no vertical pinning should be necessary for this.

Otherwise, if you can post a document with that card in, I’ll be happy to have a look and tell you what’s wrong :slightly_smiling_face:.

1 Like

Thank you. I’m unsure why it’s not behaving correctly.
Card test.sketch (4.0 MB)

Any luck with my file? Thanks.

Hi Derek,

Thanks for posting that document!

I’ve attached a document with a working version of what you are trying to achieve!
Essentially, the icon needs to be inside of a Symbol (which is likely going to be the case anyway) and the contents of that Symbol should be a fixed size. This allows the Symbol to resize along with the text layer, but for the icon to remain at its actual size and centred.

I will mention that in our upcoming Stacks feature (you can find a bit more about that on our roadmap), this will be very simple to achieve!

I hope that this helps but if you have any further questions, do post and I’ll be happy to help!
Card test-2.sketch (4.0 MB)

Sorry, I’m not seeing the solution. Can you post a file with only the working version? Also, Im on Sketch version 100.3 if that matters.

Hi Derek,

I’m very sorry - I accidentally attached the wrong document.
I’ve attached the correct one now so I hope that this helps! :smile:
Card test.sketch (3.9 MB)

1 Like

Aligning icons and text with Smart Layout can sometimes be tricky, but using a fixed-size Symbol for the icon is a great approach.

1 Like