How can I align items vertically in horizontal Smart Layout?

Hello Sketch Community,

I ran into a problem trying to create a symbol for a snackbar:


Bildschirmfoto 2023-10-20 um 13.41.50

As you can see on the screenshots, the snackbar symbol is made of a vertical, top to bottom smart layout to make the snackbar grow downwards for cases of longer messages. To align the icon with the message, I grouped both into a horizontal, left to right Layout.

I pinned the icon to the top and bottom edge, hoping that would align it vertically in the middle when the text grows next to it:

Bildschirmfoto 2023-10-20 um 13.47.22

Unfortunately it stays pinned to the top of the Snackbar:

But this was my desired outcome:

I tried to figure out how to make it work with other settings such as changing the group layout from horizontal to vertical but it only stretched the icon and I wasn’t able to fix its size. I am pretty new to Sketch and I’m sure there must be a solution for this problem, I would appreciate any help or tips! :slight_smile:

Hey!

Would you mind sharing this Component in an isolated Document? We’d love to take a look at it and see if we can get it to work the way you want.

I’m somewhat confident we have provided similar solutions to customers in the past, but it kind of depends on the way the Component is setup and we just want to make sure!

:pray:

Hello, first of all thank you for replying! Here you go:

Snackbar.sketch (586.3 KB)

Thanks!

Hey thanks a lot for the fast reply!

Here’s what you need to do:

  • Select the Icon element and remove the Pinnings. Also, make this element Fixed size (so it doesn’t stretch when SL kicks in!)
  • Select the Group within Snackbar and:
    • Change the direction to Vertical > Middle
  • :white_check_mark: Done!

Here’s the fixed file as well! Let us know if this helps!
Snackbar.sketch (587.4 KB)

2 Likes

Oh thank you so much for the quick fix! Makes a lot of sense now that I see how it’s done. :pray:

1 Like