Create and manage variables
If you're using UI3, Figma's new design, some parts of this article might not match what you see in the product today. We appreciate your patience while we make updates. Learn more about Figma’s redesign →
Before you Start
Who can use this feature
Anyone on any plan
Anyone with can edit access to a file can create and edit variables
Looking for more resources on variables? Check out our guide to variables →
Access the Variables modal
Use the Variables modal to create and manage variables, modes, groups, and collections.
- Deselect everything on the canvas by pressing esc or clicking the canvas.
- From the right sidebar, find the Local variables section.
- Click Open variables.
Create a variable
Note: You can create up to 5,000 variables per collection.
- From any collection, click + Create variable.
- Select a variable type from the dropdown.
- Give the variable a name in the first column, and a value in the second column.
To duplicate a variable, select one or more variables and press ⇧ Shift Enter.
To delete a variable, right click the variable and select Delete variable.
Tip: A variable can store multiple values, allowing for more dynamic designs. Learn how to create multiple modes for variables →
Create an alias
Create an alias for a variable to link its value to an existing variable. This allows you to implement design tokens and makes managing updates to your designs more efficient.
For example, say you have multiple color variables that reference the same color variable. If that color needs updating, you would only need to update the source instead of manually updating every instance of the color.
A variable can reference other variables of the same type.
To create an alias for a variable:
- Open the Variables modal.
- Right-click a variable’s value and select Create alias.
- From the Libraries tab, choose a variable to set an alias. You can use the search bar to find a variable by name or browse through enabled libraries.
To detach an alias, hover over the value field and click Detach alias.
Edit a variable
Hover over a variable’s row and click the Edit variable icon to open its editing modal.
From there, you can:
- Change the variable’s name
- Add a description to explain how a variable should be used
- Modify the variable’s value
- Use the checkboxes to scope a variable ↓
- Add code syntax ↓
- Hide the variable from publishing →
Scope a variable
Scope a variable to limit which properties the variable can be applied to. This reduces the guesswork when choosing variables for designs.
For example, if you scope a number variable to corner radius, the variable can only be applied to corner radius and won't appear as an option for any other supported properties.
Scoping is available for number, color, and string variables.
For number variables, you can scope:
- Auto layout
- Gap between
- Padding
- Corner radius
- Font properties
- Font weight
- Font size
- Line height
- Letter spacing
- Paragraph spacing
- Paragraph indent
- Layer opacity
- Effects
- Stroke
- Text content
- Width and height
For color variables, you can scope:
- Effects
- Frame fill
- Shape fill
- Stroke
- Text fill
For string variables, you can scope:
- Font family
- Font weight or style
- Text string
To scope a variable:
- Right-click on a variable, or multiple variables, and select Edit variable. You can also click Edit variable, located to the right of any single variable.
- Open the Scoping tab.
- Use the checkboxes to toggle the variable’s availability in that property. Check Show in all to make the variable available for all supported properties.
Add code syntax
Code syntax allows you to represent variables in code using valid variable names to support a seamless handoff experience. A variable’s code syntax will appear in code snippets in Dev Mode when inspecting elements using the variable. Currently, code snippets for variables are supported in CSS, SwiftUI, and Compose.
You can create one name per platform, including Web, Android, and iOS. This allows for up to three code syntaxes per variable.
To add code syntax to a variable:
- From the Code syntax section of the the Edit variable modal, click Add code syntax.
- From the dropdown, choose Web, Android, or iOS.
- Use the input box to enter a variable name. A preview shows how the variable name appears in code snippets.
Edit variables in bulk
To edit multiple variables at once:
- Open any collection from the Variables modal.
- Select multiple variables by using keyboard shortcuts:
- Hold ⌘ Command / Control and click to select individual variables
- Hold Shift and click to select a range of variables
- Right-click a selected variable and click Edit variables.
- From the Edit variables modal, you can:
- Scope variables, if supported by the variable type
- Hide variables from publishing
Group a selection of variables
To organize variables into a group:
- From the Variables modal, select multiple variables:
- Hold ⌘ Command / Control to select multiple variables
- Hold ⇧ Shift to select a range of variables
- Right-click the selection and select New group with selection.
Click and drag groups in the sidebar of the Variables modal to reorder groups. You can also click and drag groups into other groups to nest them.
Rename a group
- From the Variables modal, click Toggle sidebar so that it’s visible.
- Double click the group name.
- Type a new name for the variable group.
Manage a group
- From the Variables modal, click Toggle sidebar so that it’s visible.
- Right-click the group name in the sidebar.
- From the menu, choose from the following:
- Ungroup
- Duplicate group
- Delete group
Create and manage variable collections
To create a variable collection:
- From the Variables modal, click Toggle sidebar so that it’s visible.
- Open the collection dropdown and select Create collection.
To rename or delete a collection of variables:
- From the Variables modal, click Toggle sidebar so that it’s visible.
- Open the collections dropdown and choose the collection you want to manage.
- Open the collections dropdown again and select Rename collection or Delete collection.
Ready to continue your variables journey? Check out the following topics: