Zurück
Joshua Schär
5. November 2018

Amazing Sketch Update 52 - Adaptive Text and Style Overrides

Since version 52 of Sketch, there is a bunch of new amazing stuff! 🎉

But I’m only gonna focus on two awesome features. And before you leave because adaptive text is not actually (or officially) part of the update and you are angry because of clickbait, hear me out.

Adaptive text is not something totally new, but clearly improved since the newest version. There are a few posts about the feature, but most of them are outdated, too complicated, too long or simply untrue.

1. Adaptive Text: What It Is and How To Use It 💪

Adaptive text in Sketch is a really useful feature, but you have to first understand how it works to benefit from the magic.🔮

Other people have called it adaptive text elements, dynamic and responsive content, dynamic size of symbols, dynamic buttons or dynamically moving symbols. But they all talk about the same thing.

In a thread on the Graphic Design Stackexchange, a user asked a question that can be solved with adaptive text. The question was how to make an object automatically move when the text preceeding/“attached to“ it is changed. I didn’t really understand all of the answers given to the question in the thread. Some of the answers are not true anymore, since the newest update 52.

This is why I’d like to clarify with my own explanation. I’m gonna use lots of gifs.

Here’s how the question posed on the Graphic Design Stackexchange is solved with adaptive text:

Adaptive Text in Action. In the past, people even used plugins to achieve this effect. But I've got good news for you: there's no need to use a plugin.
Adaptive Text in Action. In the past, people even used plugins to achieve this effect. But I've got good news for you: there's no need to use a plugin.

1.1 Creating Symbols ✨

In order to use adaptive text as shown in the gif above, you have to first create symbols. Here’s a quick overview of what symbols are and what they do.

Ever designed a dialog with two actions (links or buttons) next to each other? At some point, you may want to reuse the same dialog on another screen but with different content. In order to do this, you will create a symbol.

In Sketch, we want to make smart use of symbols. This basically means that we want to create symbols in a way that they are as dynamic as possible. I try to keep the amount of symbols to a minimum by using the awesome symbol override feature. Overrides allow you to edit parts of your Symbol instance, for example overriding text. You can even nest other symbols in your symbol. This allows you to swap the nested symbols with any other symbol that has the same size. Here’s an example of the power of symbols:

Easily swapping symbols that have the same size.
Easily swapping symbols that have the same size.

1.2 Rules of Adaptive Text 🎓

What happens if you want to change the button text to be longer or shorter? In order to do this, you do not need to create a new symbol. You can simply override the button text in the inspector. There is not much you need to configure in your symbol in order to achieve adaptable text. There are, however, a couple of rules:

Adaptive text also works with other elements, like shapes, e.g. icons. Here’s an example to illustrate this:

Adaptive text will push over shapes, as well. Make sure text is aligned accordingly. In the example above, the text is aligned to the right. It won't work when the text layer is centered.
Adaptive text will push over shapes, as well. Make sure text is aligned accordingly. In the example above, the text is aligned to the right. It won't work when the text layer is centered.

1.3 Spacing Between Elements as a Workaround ⚒

What if you want more than 20px spacing between two elements? Well, currently you need a workaround to solve this problem. The people form bohemian coding will probably fix this in a future update of Sketch, but for now, this workaround is the best solution.

You need to add something in-between the two text layers. You can use another text layer or a shape, but just make sure this workaround-layer is hidden so it is not visible. In the example gif below, I inserted the dialog symbol on the symbol page. If I make changes to the symbol, I can immediately see the effect on the symbol instance below it. First you can see, that the adaptive text for the two action buttons won’t work because the spacing between those two layers is 30px. After I added a shape (workaround-layer) between the text layers, the adaptive text works. Yay. 🎉

Using a shape workaround-layer to bridge the 20px spacing constraint.
Using a shape workaround-layer to bridge the 20px spacing constraint.

There is, however, another constraint. The height of the workaround-layer must not be higher than the height of the adaptive text layer. It won’t work otherwise. 🤦‍♂️ I demonstrate this below:

The workaround-layer layer must not be higher than the adaptive text layers.
The workaround-layer layer must not be higher than the adaptive text layers.

As you can see, adaptive text starts to work as soon as the height of the green shape is less than the height of the text layers.

2. Style Overrides 💅

Another amazing feature in Sketch are style overrides. With the new Sketchapp Version 52, you can override styles. This is how it’s done:

Style overrides in action.
Style overrides in action.

Notice how the layers change their color when applying a text or layer style on them:

This goes for icons, too! Before, I used color symbols and masked them with the icon path. Now, I can just define layer styles and use them directly on the symbol instance.

Using color layer style overrides on an icon symbol
Using color layer style overrides on an icon symbol

Such wow 🐕. Notice that the three download icons shown above are three separate symbol instances of the same symbol. And yes, in this case, it would probably make sense to union the two paths „Bottom“ and „Arrow“ so that you can override the layer color once for the whole icon.

Style overrides are great for two things: it forces you to actually work with text and layer styles. This brings more consistency in your design and speeds up your work because you don’t have to adjust several text style properties anymore. It also means you use fewer symbols which simplifies your workflow and reduces the file size.

Let me show you an example of what I mean. I created a card for a mobile app project recently, and this card emphasises the price information:

I needed to use the same card in another context. Rather than emphasising the price located in the top right corner (original card), however, I wanted to place emphasis in the top left of the card (new card).

Before Sketch version 52, I had to duplicate (or detach) that symbol and change the text styles accordingly. With version 52, I can just make use of this awesome text style override feature. Check this out:

Using text style overrides on a symbol.
Using text style overrides on a symbol.

This makes my work so much easier because it reduces the amount of symbols drastically. Thanks for that, bohemian coding people!

This is the best article I found on the topic of style overrides, by the co-founder of UX Power Tools. But brace yourself, there is some self promotion marketing there. 🤐

You can download the Adaptive Text Example (zip) that I used for this blog post to see more details.