Scopes and Code Syntax
Where a variable is offered in Figma and how it is named in Dev Mode: the Scopes and Code Syntax sections of the token form, the $extensions field in JSON, allowed scopes per variable kind, code syntax templates and inheritance.
Two variable settings are set in the token form and stored in $extensions:
| Setting | Controls |
|---|---|
Scopes (figma.scopes) | In which Figma fields the variable is offered |
Code Syntax (figma.codeSyntax) | How the variable is named in Dev Mode for the Web, Android and iOS platforms |
Both are optional and affect only types that export as variables. Styles and internal types have no such sections. They are written to Figma when the Apply codeSyntax & scopes switch in the Export to Figma window is on, which it is by default.
{
"color": {
"brand": {
"$type": "color",
"$value": "#635BFF",
"$extensions": {
"figma.scopes": ["ALL_FILLS", "STROKE_COLOR"],
"figma.codeSyntax": { "Web": "var(--color-brand)", "iOS": "Color.brand" }
}
}
}
}
Where to set them
- In the create or edit form of a token: the Scopes and Code Syntax sections.
- For many tokens at once: in the collection table select rows and choose Edit token fields… in the context menu, which has the same Scopes and the Code Syntax fields for Web, iOS and Android. Inherit from group… restores inheritance from the group. See Collections.
- In JSON: the
$extensionsfield of a token or a group.
Scopes
A scope limits the Figma fields in which a variable is offered. The set of allowed scopes depends on the variable kind the token type exports to.
| Variable kind | Token types |
|---|---|
| Color | color |
| Number | opacity, dimension, number, spacing, sizing, borderWidth, borderRadius, fontSize, lineHeight, letterSpacing, paragraphSpacing, paragraphIndent |
| String | fontFamily, fontWeight, text |
| Boolean | boolean |
| Timing | duration |
| Easing | cubicBezier, easing |
Allowed scopes per kind
Other values are treated as an error by the editor and are not written to Figma.
| Kind | Allowed figma.scopes |
|---|---|
| Color | ALL_SCOPES, ALL_FILLS, FRAME_FILL, SHAPE_FILL, TEXT_FILL, STROKE_COLOR, EFFECT_COLOR |
| Number | ALL_SCOPES, TEXT_CONTENT, CORNER_RADIUS, WIDTH_HEIGHT, GAP, STROKE_FLOAT, EFFECT_FLOAT, OPACITY, FONT_SIZE, LINE_HEIGHT, LETTER_SPACING, PARAGRAPH_SPACING, PARAGRAPH_INDENT, FONT_WEIGHT |
| String | ALL_SCOPES, TEXT_CONTENT, FONT_FAMILY, FONT_STYLE |
| Boolean, Timing, Easing | Scopes are not supported; the field must be absent or empty |
ALL_SCOPES means "everywhere" and cannot be combined with other values. For fontWeight only FONT_STYLE is allowed: Figma stores the face as a string, so the FONT_WEIGHT scope does not fit it and causes a file validation error.
Default scopes
If figma.scopes is not set, the plugin picks a scope by type. Variable types not in the table get ALL_SCOPES.
$type | Default scope |
|---|---|
color | ALL_FILLS, STROKE_COLOR, EFFECT_COLOR |
sizing | WIDTH_HEIGHT |
spacing | GAP |
borderRadius | CORNER_RADIUS |
borderWidth | STROKE_FLOAT |
opacity | OPACITY |
fontFamily | FONT_FAMILY |
fontWeight | FONT_STYLE |
fontSize | FONT_SIZE |
lineHeight | LINE_HEIGHT |
letterSpacing | LETTER_SPACING |
paragraphSpacing | PARAGRAPH_SPACING |
paragraphIndent | PARAGRAPH_INDENT |
dimension, number, text | ALL_SCOPES |
{
"spacing": {
"$type": "spacing",
"md": { "$value": "16px", "$extensions": { "figma.scopes": ["GAP", "WIDTH_HEIGHT"] } }
}
}
Code Syntax
figma.codeSyntax sets the string that Dev Mode shows next to the variable, separately per platform. All keys are optional.
| Key | Platform | Example |
|---|---|---|
Web | CSS, SCSS, Less | var(--color-brand), $color-brand |
Android | Kotlin, XML | ColorBrand, @color/brand |
iOS | Swift, SwiftUI | Color.brand, UIColor.brand |
{
"$extensions": {
"figma.codeSyntax": { "Web": "var(--color-brand)", "Android": "@color/brand", "iOS": "Color.brand" }
}
}
Templates
Instead of a name for every token, set a template: the plugin builds the name from the token path.
| Template | Result for color.brand.primary |
|---|---|
{var(--css-variable)} | var(--color-brand-primary) |
{$sass-variable} | $color-brand-primary |
{@less-variable} | @color-brand-primary |
{UpperCamelCase} | ColorBrandPrimary |
{lowerCamelCase} | colorBrandPrimary |
{UPPER_SNAKE_CASE} | COLOR_BRAND_PRIMARY |
{lower_snake_case} | color_brand_primary |
{
"$extensions": {
"figma.codeSyntax": { "Web": "{var(--css-variable)}", "Android": "{UpperCamelCase}", "iOS": "{lowerCamelCase}" }
}
}
The path is split into words at the /, . and _ separators, and the template joins the words in its style.
Inheritance
Set $extensions on a group, and every token inside inherits it. A token may override an individual key; the other keys are merged.
{
"color": {
"$type": "color",
"$extensions": { "figma.scopes": ["ALL_FILLS", "STROKE_COLOR"] },
"brand": { "$value": "#635BFF" },
"brand-strong": {
"$value": "{color.brand}",
"$extensions": { "figma.scopes": ["STROKE_COLOR"] }
}
}
}
The token badge tooltip shows that settings are inherited from the group.
Full example
{
"color": {
"$type": "color",
"$extensions": { "figma.scopes": ["ALL_FILLS", "STROKE_COLOR"], "figma.codeSyntax": { "Web": "{var(--css-variable)}" } },
"brand": {
"primary": { "$value": "#635BFF" },
"on-primary": { "$value": "#FFFFFF", "$extensions": { "figma.scopes": ["TEXT_FILL"] } }
}
},
"radius": {
"$type": "borderRadius",
"md": { "$value": "8px", "$extensions": { "figma.scopes": ["CORNER_RADIUS"] } }
}
}