Sketch: “Overriding” the color of text layers in symbols.

Francesco Bertocci
Prototypr
Published in
4 min readFeb 23, 2017

--

UPDATE: this post was originally posted in Feb 2017. Many versions of Sketch ago!

Now that Text & Layer styles have been released with Sketch 52, you no longer need this hack and you can simply override the styles. Leaving the post below for the record! :)

The techniques in this post are workarounds that will not be necessary if/when Sketch will support — hopefully soon:
- Native color overrides (or better styles overrides)
- Text layers as masks

The biggest advantage of using this technique is that your text will stay editable – there’s other ways to achieve this effect like having multiple text layers in one symbol and hiding the ones you don’t want to use for that symbol instance, or converting the text layer to outlines and using it as a mask.

Works great – except on non-white backgrounds :/

1) Symbols setup

– Color layer with blend mode
– Text layer/s
– White background

The symbol MUST bet set this way: Color symbol on top set to “Screen”, black text layers in the middle and white bg at the bottom (without this white background the hack won’t work and you’ll go nuts!)

I had initially started this post using #808080 for text and “Color” as blending mode. It seemed to work fine except with gradients. Then I read a great post on creating SVG icons from Anthony Collurafici and switched the text to black and the blend mode to “Screen” and it works much better! I had to also redo all the screenshots :/ but totally worth it!

This color works too for text but not as well as black

Back to our symbol…
To achieve the color override we have to make the color of the text layer itself #000 (black). I created a style too (you don’t have to for the effect to work) because it’s useful if you use this technique in multiple symbols within the same file, creating the style will allow you to update things waaay faster.

Text layers you want to be able to override need to be #000 (black)

…so that we can use layer colors (symbols) with Screen (Blending mode) to affect the black layers below.

This method works with text layers that have been turned into symbols too but it was overkill for this tutorial. Nested symbols are awesome :)

Important: you also need a white background layer to make sure the color layer affects the text layer or it won’t work!

Don’t forget the white background layer!

2) Create symbols (And layer styles) for each color

Remember to make the color swatches big enough to cover the text area — including the longest text override you plan to use. A good starting point is to match the area of the text area.

And you are done!

Note the gif here shows the text layer at #808080 but you want to use #000 per my notes above.
  1. Download the file.
  2. Edit the symbols and see how they are set up.
  3. Change color fills and see how they affect the text.

Take it to the next level by playing with nested symbols for the text layers :)

If you have any tips on other ways to do cool things with symbols and overrides, shoot me an email at Francesco@FreeAndWilling.com or add a comment below. I appreciate your feedback.

If you learnt something from the post or the file — pls like the post and share. If you are in NYC and are are into Sketch, Principle or InVision make sure to join the meetup.

Thank you :)

Francesco
@fbmore
@FreeAndWilling

--

--