2

I want to create a symbol with an overridable text field that is empty by default. The problem is that Sketch automatically removes text fields that contain no text. I tried setting the text to various whitespace characters but Sketch still removes the text field.

The only workaround I found was to make a symbol of the text too and set the override to an empty string but that creates unwanted side effects (for example the text field symbol will also be overridable).

Is there another way to achieve this?

  • I don't see a point in this. You can always override the text in the symbol with a "space" character. – Spasimir Dinev Feb 8 '17 at 13:46
1

My work around is, to use a soft hyphon (0xAD) (the character between these two: - ­-) as the default text. It's invisible, but sketch will keep the text element. You add it by Control+Cmd+Space, switch to full view and search for soft.

  • Works beautifully! – filip Feb 16 at 5:58
5

Make the text layer within your symbol a symbol itself. Make sure to set the text layer symbol to Resize Object not Stretch. The text layer object should be sized for your full text area.

enter image description here

Then, when you use the symbol, the text layer will resize properly with the field. You'll be able to override the text, as well as choose None which will remove the text symbol, for no placeholder text.

enter image description here

What makes this really powerful is you can duplicate this placeholder text symbol layer to make different colored text, for example to represent filled text AND placeholder text. Simply ensure that the symbols you want to have the option to switch between are the exact same size. enter image description here

Then, on the main screen, you'll be able to select between these symbols.. including none for a blank text field!

enter image description here

1

If you don't want to make "placeholder" a symbol, you can leave it as text and then in the instance of the Text Field symbol, enter a space in the override field. This will make the field appear empty though still allow for input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.