How To Use Sketch’s Resizing Symbols Like A Boss

Jérémy Paul
Design + Sketch
Published in
8 min readSep 1, 2016

EDIT: This article was written before the release of Sketch 44. At the time, there were 4 modes: Stretch, Pin to corner, Resize object, and Float in place. Now it’s a little bit different, so please note that this tutorial is slightly outdated. There is now a much cleaner way to handle the progress bar issue. The downloadable file has been updated accordingly, so make sure to check out how it’s made. Thanks for all the responses and kind comments ;)

Since I’ve been designing apps, you could’ve seen me complaining once or twice about the designer softwares, especially their lack of features that aim towards interaction and behaviour. Indeed, we ought to design actual systems that can react to context (e.g. screen sizes, content, brand guidelines…), rather than creating dull images that are really just pixels. Not only is it more comfortable to do so, but it also allows us to express our true intentions in our work files, making them clearer for everyone.

Fortunately, creating systems is now possible in a far more advanced way than even one year ago, thanks to Bohemian Coding and their unstoppable Sketch app. These guys get it.

Although we’ve been familiar with Symbols for quite a while, it was only a part of the solution. But recently, Sketch’s developers have brought to designers two marvellous features that are truly game changers: nested symbols, and resizing symbols. While the first one allows a long awaited comfort for users that I’m not going to dig into, the second one is, in my opinion, a real revolution within the UI design world. It’s the ability for designers to dip into the developers’ world of constraints, and to show a better sense of how an element is articulated. This is huge!

Think about it: now, a UI element is not just an image, or a vector, it has become a component whose instances can adapt differently to the context in which they are displayed. For example, the same nav bar can be applied to an iPhone or iPad-sized artboard, and/or have different titles throughout the screens. Item instances from a grid view can have their own text and image contents and look different, while referring to this one master element, or symbol, that defines a behaviour. Make modifications to this symbol and they will be applied everywhere. Edit one instance at a time to add context. Welcome to the point where it finally gets exciting!

Tutorial: the responsive YouTube player

Before we get practical, I’d like to apologize for the rather pretentious title of this article.

Now, let’s get started! I’ll show you, as an example, how I made the YouTube player using Sketch 39 and the new symbol resizing feature. I’ll make sure to share some nice tips along the way. Some of it was actually quite a challenge, so stay focused! I can only encourage you to check out the intro to resizing rules before going any further.

The file is available to download for free, right over here. I’m sure you can find some use for it in your web projects, so feel free!

If you’re already familiar with these tools, please jump to The Progress Bar section. That’s where the real catch is. If you’re not sure and want to grab some extra tips, you’re welcome to follow along!

Building the player

Before applying any rules, let’s just build and compose the final component like you normally would in Sketch, at a default size. For better accuracy, using a screenshot is definitely a good idea. Create the icons, the progress bar, put a rectangle behind with an image set to fill the content (see image below), and that’s basically it! If elements of a certain kind are in numbers, like icons in this case, create a shared style for convenience.

At this point, make it a symbol. You’ll be editing it in the Symbols page and testing it in whatever page you’d like to display an instance of it. It can be right next to the main symbol itself. The final comp should look like that:

Preparing the layers

Next step: create bounds to unify the glyphs. Icons are pretty much like typographic characters. They don’t have necessarily the same size per se, but are implicitly included inside invisible boxes that have the same dimensions. I call these boxes Bounds. I usually define the same rectangle around each icon (here, 36x36px), and group every icon with its bounding box individually. In this case, it helped understanding the layout of the player controls, using empty space around them as a grid. All the bounds layers must be invisible, so I create a shared style called _Bounds that has fill and border deactivated.

What’s important to notice is that even though this step represents visually nothing, it will have its role to play in the rules we’re about to apply: preventing unwanted offsets when resizing the symbol.

Adding resizing rules, or constraints

Actually, we’ve already started when we put the background image on Fill mode. This is not new in Sketch, but still pretty handy. Alternatively, you can use the Fit mode, depending on what you want to achieve (the Fit mode is new, by the way). These modes ensure that the image is always going to fill or fit the available area when resizing.

Then, all the icons and controls composing the player have to stay at the same distance from the closest corner, keeping the same size if its parent is resized. Well, we’ve got just the thing! Use Pin to corner instead of the default Stretch option in the inspector on the right. If you group them, make sure that these groups are also set to Pin to corner. Double check if the size is sufficient so every item is positioned near a corner and not equidistant from two corners, or it will stick in the middle of them.

As for the gradient, you want it to resize with the whole component, so set it to Resize object. Simple as that!

So, the background image will behave using fill or fit, the controls will stick to the closest corners, and the gradient will resize dynamically. Good job! But until now, no surprise.

The progress bar

Oh wait, there’s still this iconic red progress bar that we need to deal with. YouTube wouldn’t be YouTube without it!

Here’s the wanted behaviour: the progress and loading bars must stick to the left using always the same margin. Same for the bottom with a different fixed value. Optionally, they need to represent the same percentage of progress at any size. The overall bar has to be centered horizontally, using the same fixed margin on both sides and at any size. Same for the bottom.

In other words, we need the bars to be resizing horizontally, but not vertically, and stick at always the same distance from the left and right edges, and bottom edge.

Thing is, with the four available options Sketch has in store for us (Stretch, Pin to corner, Resize object, and Float in place), my first thought was: it cannot be done. Trust me, I’ve tried.

But this is how it gets interesting: you can make a combo! Wouldn’t it be great to use a little bit of both rules? Well, it’s actually not really possible, but with a little mind fucking session, I managed to find a solution. Here’s the explanation:

First, we need to define an area that keeps the same distance from the left and right edges at all times. It also needs to have a fixed distance from the bottom edge. And that’s kind of what Resize object’s does. So create a rectangle that fills the screen, minus a 12px margin on the left, same on the right, and 37px on the bottom (why not 36px, YouTube?). Group it, and set the group to Resize object. Try it. It should behave like so:

Now that we have the basics, let’s make this area invisible. What we want for the bars is to always stay at the bottom of this area, keeping their proportions horizontally but have a fixed height. That means you want to stretch them to that newly defined area, without effecting its height. This is not possible using plain shapes, like rectangles, but a simple line with a defined stroke (in that case, 3px), will not be resized in thickness — up to a point, rather extreme : <152px. Not exactly sure why. But let’s not care about it.

Place the progress, laoding and global bars as stroke lines inside the group area, and make sure they snap to the bottom. By default, they are set to Stretch. That should do the job!

Now, you can modify the size of the instances, and even the content using Overrides — time elapsed, global time, background image.

This case being pretty specific, there’s still a solution. It might not be the case for every situation, nor the most elegant one, but you can make it work. Hats off to Bohemian Coding, who made a first version of these constraint tools very handy and rather simple to use despite a small time of adaptation. Who knows what options they will be able to add in the future? Responsive design is finally here at the right stage, and it’s surely for the best!

If you’ve downloaded the file, you may have noticed that I created three versions of the same player: embedded, embedded hover, and playing. Three versions, three symbols. While you can edit the content of every instance and change the template by switching the symbol, it would be great to be able to set up multiple compositions of the same symbol, hiding or showing the appropriate groups within the symbol, much like Photoshop’s layer comps. That would add another dimension to a component’s behavior.

Having said that, I know how these guys like to keep Sketch as tidy, comprehensive and straightforward as can be, and they’re the experts. Gotta love ‘em for that!

Looking forward to see the next features and improvements! See you for the next breakthrough feature ;)

--

--

Jérémy Paul
Design + Sketch

My job consists in eliminating chaos from products so humans can enjoy using them. Co-founder of @monoqle_ and @happyh0urs coworking.