PaintCode Power User: Variables

This post is a part of series PaintCode Power User.

Variables are a feature you won’t find in any other design tool. PaintCode brings very basic concept from programming to design in a simple and visual way. Just like Library Colors, that are created once and then shared by multiple shapes, Variables work the same for any numeric values.

Imagine you need to use consistent stroke width across your icons, so you create a Variable called Thickness of type Number and set its value to 1. You then connect this Variable to Stroke Width attribute in the Inspector of multiple shapes. Later, you can change value of this Thickness Variable and all shapes will be updated immediately.

Variable TypesVariable Types

Although Variables are part of Library, they are special in several ways and cannot be exposed in programming interface of StyleKit. They are often used as parameters of Symbols or canvases in generated code.

Special kind of Variables are those defined using an expression. I will write a dedicated post about Expressions later.


Every Variable needs to have a type and you need to pick it when creating a Variable. Here are the types:

Custom Expressions may evaluate any of these types, with the exception that Number, Fraction and Angle are not distinguished. You probably noticed that types like Boolean or String have quite limited usage, but their true potential is hidden in Expressions. More on that in a future post.

Tips for Variables

Variable Connection to Text FieldVariable Connection to Text Field Variable Connection to CanvasVariable Connection to Canvas Touch Bar Editing of VariablesTouch Bar Editing of Variables Popover for Editing Offset of VariablePopover for Editing Offset of Variable

Variables will probably encourage you to think about your designs in new ways. Ability to dynamically connect multiple seemingly non-related attributes of different Shapes, allows you to give a concrete meaning to the bunch of objects on your canvas.

To learn more about Variables, read our Variables documentation or watch a video about Variables.