Scopes & Code Syntax
Configure Figma variable scopes and Dev Mode code syntax through $extensions in SXL Studio tokens — valid scopes per type, defaults, templates, and examples.
Overview
Two $extensions settings control how a variable behaves after export:
| Extension | Controls |
|---|---|
figma.scopes | Where a variable can be used in Figma (its scope / visibility) |
figma.codeSyntax | How the variable appears in Dev Mode per platform (Web, Android, iOS) |
Both are optional. Scopes only apply to types that export as variables (color and the FLOAT / STRING / BOOLEAN types); style and internal types ignore them.
{
"color": {
"brand": {
"$type": "color",
"$value": "#635BFF",
"$extensions": {
"figma.scopes": ["ALL_FILLS", "STROKE_COLOR"],
"figma.codeSyntax": { "Web": "var(--color-brand)", "iOS": "Color.brand" }
}
}
}
}
Scopes
A scope limits which Figma fields a variable is offered in. Each token type resolves to one Figma variable kind (COLOR, FLOAT, STRING, BOOLEAN), and each kind allows a fixed set of scopes.
Figma variable kind by token type:
| Kind | Token types |
|---|---|
COLOR | color |
FLOAT | opacity, dimension, number, spacing, sizing, borderWidth, borderRadius, fontSize, lineHeight, letterSpacing, paragraphSpacing, paragraphIndent |
STRING | fontFamily, fontWeight, text |
BOOLEAN | boolean |
Valid scopes by kind
Only these scope values are accepted for each variable kind (others are dropped on export).
| Kind | Valid figma.scopes |
|---|---|
COLOR | ALL_SCOPES, ALL_FILLS, FRAME_FILL, SHAPE_FILL, TEXT_FILL, STROKE_COLOR, EFFECT_COLOR |
FLOAT | 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, FONT_VARIATIONS |
BOOLEAN | ALL_SCOPES |
Note An invalid scope for a type is silently filtered out on export. For example, CORNER_RADIUS on a color token is ignored.
Default scopes by type
If you do not set figma.scopes, SXL Studio applies a sensible default per type. Types not listed default to 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, boolean | ALL_SCOPES |
{
"spacing": {
"$type": "spacing",
"md": { "$value": "16px", "$extensions": { "figma.scopes": ["GAP", "WIDTH_HEIGHT"] } }
}
}
Code Syntax
figma.codeSyntax sets the string shown for a variable in Figma Dev Mode, 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" }
}
}
Code Syntax templates
Instead of writing a name per token, use a template — SXL Studio generates the value 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}" }
}
}
How the path converts Separators
/,.,_become-, the path is split into words, and each template formats those words in its style.
Inheritance
Set $extensions at the group level and every token inside inherits it. A child can override a single key; non-overlapping keys merge.
{
"color": {
"$type": "color",
"$extensions": { "figma.scopes": ["ALL_FILLS", "STROKE_COLOR"] },
"brand": { "$value": "#635BFF" },
"brand-strong": {
"$value": "{color.brand}",
"$extensions": { "figma.scopes": ["STROKE_COLOR"] }
}
}
}
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"] } }
}
}