Skip to main content

Types

Variables in Figma have preset types (string, boolean, float, etc…), belong to a variable collection, and hold a different value for each mode in the collection. Certain node properties can bind to variables, enabling these properties to change dynamically when variables are updated or when the node is associated with a different mode.

The below types are returned by the GET local variables and GET published variables endpoints, with the published variables endpoint returning a subset of these properties. Please refer to the return values for each endpoint for more details.

NameProperties

VariableCollection

A grouping of related Variable objects each with the same modes.

idString
The unique identifier of this variable collection.
nameString
The name of this variable collection.
keyString
The key of the variable collection.
modesMap<String, String>
A map of modeId to mode name for this variable collection.
defaultModeIdString
The id of the default mode.
remoteBoolean
Whether the variable collection is remote.
hiddenFromPublishingBoolean
Whether this variable collection is hidden when publishing the current file as a library.
variableIdsString[]
The ids of the variables in the collection. Note that the order of these variables is roughly the same as what is shown in Figma Design, however it does not account for groups. As a result, the order of these variables may not exactly reflect the exact ordering and grouping shown in the authoring UI.

Variable

A Variable is a single design token that defines values for each of the modes in its VariableCollection. These values can be applied to various kinds of design properties.

idString
The unique identifier of this variable.
nameString
The name of this variable.
keyString
The key of the variable.
variableCollectionIdString
The id of the variable collection that contains this variable.
resolvedTypeString

The resolved type of the variable, as a string enum.

  • BOOLEAN
  • FLOAT
  • STRING
  • COLOR
valuesByModeMap<String, Boolean | Number | String | Color | VariableAlias >
The values for each mode of this variable.
remoteBoolean
Whether the variable is remote.
descriptionString
Description of this variable.
hiddenFromPublishingBoolean

Whether this variable is hidden when publishing the current file as a library.

If the parent VariableCollection is marked as hiddenFromPublishing, then this variable will also be hidden from publishing via the UI. hiddenFromPublishing is independently toggled for a variable and collection. However, both must be true for a given variable to be publishable.

scopesVariableScope[]

An array of scopes in the UI where this variable is shown. Setting this property will show/hide this variable in the variable picker UI for different fields.

Setting scopes for a variable does not prevent that variable from being bound in other scopes (for example, via the Plugin API). This only limits the variables that are shown in pickers within the Figma UI.

codeSyntaxVariableCodeSyntax
Code syntax definitions for this variable. Code syntax allows you to represent variables in code using platform-specific names, and will appear in Dev Mode's code snippets when inspecting elements using the variable.
deletedButReferencedBoolean
Indicates that the variable was deleted in the editor, but the document may still contain references to the variable. References to the variable may exist through bound values or variable aliases.

VariableAlias

An object that serves as an alias for a variable. All properties are required.

typeString
VARIABLE_ALIAS
idString
The id of the variable that this alias points to. In the POST variables endpoint, you can use the temporary id of a variable.

VariableScope

Scopes allow a variable to be shown/hidden in the variable picker UI for various fields. This declutters the Figma UI if you have a large number of variables. Currently only supported on FLOAT and COLOR variables.

ALL_SCOPES is a special scope that means that the variable will be shown in the picker UI for all current and any future fields. If ALL_SCOPES is set, no additional scopes can be set.

Likewise, ALL_FILLS is a special scope that means that the variable will be shown in the picker UI for all current and any future color fill fields. If ALL_FILLS is set, no additional fill scopes can be set.

Valid scopes for FLOAT variables:

  • ALL_SCOPES
  • CORNER_RADIUS
  • TEXT_CONTENT
  • WIDTH_HEIGHT
  • GAP
  • STROKE_FLOAT
  • OPACITY
  • EFFECT_FLOAT
  • FONT_WEIGHT
  • FONT_SIZE
  • LINE_HEIGHT
  • LETTER_SPACING
  • PARAGRAPH_SPACING
  • PARAGRAPH_INDENT

Valid scopes for STRING variables:

  • ALL_SCOPES
  • TEXT_CONTENT
  • FONT_FAMILY
  • FONT_STYLE
  • FONT_VARIATIONS

Valid scopes for COLOR variables:

  • ALL_SCOPES
  • ALL_FILLS
  • FRAME_FILL
  • SHAPE_FILL
  • TEXT_FILL
  • STROKE_COLOR
  • EFFECT_COLOR

VariableCodeSyntax

An object containing platform-specific code syntax definitions for a variable. All platforms are optional.

Map<String, String>

A map of platform to code syntax definitions for this variable. Platform may be one of:

  • WEB
  • ANDROID
  • iOS