It’s been a month already since Sketch released the Smart Layout feature, yet there are not so many tutorials out there covering more specific cases, rather than applying Smart Layout to the components like Buttons and Cards.
Recently I had the chance to explore this feature in real-life projects since I’m building two Design Systems at the same time right now. Truth is that it’s not that simple (at least for me) to quickly understand how to build a component and which Resizing/Smart Layout settings to apply in order to end up with a Symbol that works in a way I’d expect. That’s why today I would like to share my experience of building the System Alert Component using the Smart Layout feature. This is what we should have in the end:
Ok, enough talking. Let’s build the component already!
To build this specific component you saw above you will need the following elements: 3 shapes, 2 lines (I still use a 1px rectangles for these), an icon and 4 text layers.
Now it is time to bring all the elements together. You should end up with something that looks like this:
Next, we’ll need to group some elements, otherwise the component will fall apart when being resized. Create the following groups:
At this point, we want to apply the resizing settings for each group or element. The screenshots below show you which settings I’ve used for every group and element in my component. Let’s start with the Icon group. We want it to stay fixed on the left and not stretch when resizing. We also want it to move up and down since we can have multiple lines of text in the component that we’re building.
Here it’s important to pin this group to the Left, Top and Right edges. Since we will have the Actions group on the right, it will prevent a gap forming between the groups when resizing the component (see below)
Now it’s time to set the resizing settings for the Actions group. Make sure to apply the resizing settings to all the elements first. I also encourage you to take some time and try to understand why the following resizing settings were applied to each element and in the end to the group.
Last but not least. Set a custom width for these text layers (in my case it’s 168 px), select Auto Height in the Alignment section and all 4 options in Pin to Edges area.
Aaand we’re finally ready to create the Symbol! Select two groups together with two text layers (Title, Description), hit ‘Create Symbol’ and select Top to Bottom Layout. That’s it! Now the component should work as intended.
You can now try to override the text inside it, resize it as you wish and it should automatically fit the content and follow resizing rules that we’ve set before. If after the resizing the component looks ‘broken’ make sure to hit the ‘Shrink Instance to fit content’ button (you will find it in the Overrides panel). In case you need my original .sketch file you can download it here.
So, yeah. Such a small component requires quite a lot of actions to be taken. But it is amazing what Sketch is capable of doing already with this feature. And I can only imagine how many hours it will save us in the future while we continue designing digital products.
At the moment I am working on a Design System of my own, where I’m trying to apply Smart Layout to as many components as possible. Don’t hesitate to subscribe and I will let you know when it is ready to use.
Additionally, you can follow me on Twitter for updates and new tutorials.
Thank you for reading! I hope that today’s tutorial helped you understand the Smart Layout feature a little bit better.