Guide to Variables in Figma

Rajeev Ranjan Kumar
4 min readAug 19, 2023

--

Variables allow you to save reusable values that can be applied to different design properties like fill, stroke, padding, margin etc..

Well, seems like talking about “Style” 🤔, Not really!

Variables ≠ style

Two fundamental difference between Variable & Style

Styles can be used for properties that are made up for multiple values like (Gradients and shadow). Whereas variables can store single raw values like hex color code or string of text.

Style can’t refer another style but variable can refer another variables. This makes variables so powerful 💪.

Let’s talk about to create our first Fig. variable

Deselect everything on the canvas by pressing esc or clicking on the canvas.

Variable modal

Find the local variables section in the right sidebar and click the settings icon to open the variables modal.

Click to “Create variable” give it a type, a name, and a value.

Variable types

When creating a variable, you’ll see different types available.

Color, Number, String, Boolean

Color

Color variables can be applied to the solid fill or stroke of an object.

With the variables panel opened, click create variable and select color.

Change the name of your variable and provide the # value of color code.

Create another variable for the text label and stroke of the button.

Number

Number variables can be used to define dimensions such as width and height, spacing, padding, and radius.

Click Create variable and select String from the dropdown.

Update the variable name and value.

String

String variables can be applied to the text layers and bound to variants.
Using string variables can be helpful for repeated content and localisation.

Click Create variable and select String from the dropdown.

Update the variable name and value.

Boolean

Boolean variables are used to toggle layer visibility and really powerful in prototypes. For example, you can display a warning when a product is almost sold out, or show which products and quantities have been added to the cart.

Grouping

Organising library is always a top most primary for designer, isn’t it 😊?

let’s group them. Keep multiple sets of variables inside a collection neat and tidy by grouping them together.

Select a variable by clicking anywhere in that row.

Right-click your selection and select New group with selection from the dropdown.

Alias

When defining variables, you can create custom values or choose variables from existing libraries called Alias.

To alias a value, click the fill box and select from Libraries tab.

Select an existing variable from the list. You can pick from collections that are local or from published libraries.

Scoping Variables

You can set a recommendation as to which variable can be applied to which property for number and color types.

Scoping Variables

Hover over a number or color variable and press the settings icon.

Select and deselect where this variable should be shown at the bottom of the modal.

Applying Variables

Color variables can be used for switching between theme, like light and dark.
String variables can be used for contexts like localising language, while number variables can account for spatial changes across different device sizes.

--

--