D
D
Developers
Search…
Function List
Following is a reference list of all blueprint functions to obtain design system data:

Available Functions

Tokens

ds.allTokens

This function retrieves all tokens from the targeted design system as a flattened array. Note that this function will retrieve all tokens of all types. If you want tokens for just one type, use ds.tokensByType with appropriate type instead.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all tokens from design system
4
- Iterate through all of them
5
- List token name
6
*}
7
{[ const tokens = @ds.allTokens() /]}
8
{[ for token in tokens ]}
9
{{ token.name }}
10
11
{[/]}
Copied!
1
[{
2
"id": "149f7b03-8586-11eb-a324-c7f25166e00c",
3
"name": "Methods",
4
"description": "Methods",
5
"tokenType": "Color",
6
"origin": {
7
"source": "Figma",
8
"id": "S:32290b728349ad1f12133d58fcfa2d972477534a,",
9
"name": "Code/Methods"
10
},
11
"value": {
12
"hex": "874ce6ff",
13
"r": 135,
14
"g": 76,
15
"b": 230,
16
"a": 255,
17
"referencedToken": null
18
}
19
}]
Copied!
1
ds.allTokens(): [Token]
Copied!

ds.tokensByType

This function retrieves all tokens of a specified type from the targeted design system as a flattened array. The type can be any of the design token types.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all color tokens from design system
4
- Iterate through all of them
5
- List token name and their descriptions
6
*}
7
{[ const colorTokens = @ds.tokensByType("Color") /]}
8
{[ for token in colorTokens ]}
9
{{ token.name }}: {{ token.description }}
10
11
{[/]}
Copied!
1
[{
2
"id": "149f7b03-8586-11eb-a324-c7f25166e00c",
3
"name": "Methods",
4
"description": "Methods",
5
"tokenType": "Color",
6
"origin": {
7
"source": "Figma",
8
"id": "S:32290b728349ad1f12133d58fcfa2d972477534a,",
9
"name": "Code/Methods"
10
},
11
"value": {
12
"hex": "874ce6ff",
13
"r": 135,
14
"g": 76,
15
"b": 230,
16
"a": 255,
17
"referencedToken": null
18
}
19
}]
Copied!
1
ds.tokensByType(tokenType: TokenType): [Token]
Copied!

ds.tokensByGroupId

Because groups don't contain the tokens they carry by default (only their IDs in tokenIds property), this function retrieves all tokens of a specified group from the targeted design system as a flattened array. The type can be any of the design token types.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all groups of type "Color"
4
- Iterate through the groups
5
- For each group, fetch the associated token
6
- Iterate through tokens
7
- List token names and associated groups
8
*}
9
{[ const groups = @ds.tokenGroupsOfType("Color") /]}
10
{[ for group in groups ]}
11
{[ const tokens = @ds.tokensByGroupId(group.id) /]}
12
{{ group.name }}:
13
{[ for token in tokens ]}
14
- {{ token.name }}
15
{[/]}
16
17
{[/]}
Copied!
1
[
2
{
3
"id": "149fc92b-8586-11eb-a324-c7f25166e00c",
4
"name": "10",
5
"description": "10",
6
"tokenType": "Color",
7
"origin": {
8
"source": "Figma",
9
"id": "S:494296a45a5072718577cc0faae3bd89e6c47207,",
10
"name": "Base/Pink/10"
11
},
12
"value": {
13
"hex": "fef0f5ff",
14
"r": 254,
15
"g": 240,
16
"b": 245,
17
"a": 255,
18
"referencedToken": null
19
}
20
},
21
{
22
"id": "149fc92c-8586-11eb-a324-c7f25166e00c",
23
"name": "20",
24
"description": "20",
25
"tokenType": "Color",
26
"origin": {
27
"source": "Figma",
28
"id": "S:5642100401a4019c765b51f22f0f203de2cd1a02,",
29
"name": "Base/Pink/20"
30
},
31
"value": {
32
"hex": "fdd5e4ff",
33
"r": 253,
34
"g": 213,
35
"b": 228,
36
"a": 255,
37
"referencedToken": null
38
}
39
}
40
]
Copied!
1
ds.tokensByGroupId(groupId: string): [Token]
Copied!

Token Groups

ds.allTokenGroups

This function retrieves all token groups as a flat list.
Note that this function doesn't retrieve tokens that belong to this group. To fetch the token values as well, request the tokens by using ds.tokensByGroupId(group.id) for each group that you are interested in.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all groups in design system
4
- Iterate through the groups
5
- For each group, fetch the associated token
6
- Iterate through tokens
7
- List token names and associated groups, with their respective type
8
*}
9
{[ const groups = @ds.allTokenGroups() /]}
10
{[ for group in groups ]}
11
{[ const tokens = @ds.tokensByGroupId(group.id) /]}
12
{{ group.name }} ({{ group.tokenType }}):
13
{[ for token in tokens ]}
14
- {{ token.name }}
15
{[/]}
16
17
{[/]}
18
Copied!
1
[
2
{
3
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363c",
4
"name": "Primary Brand Borders",
5
"description": "",
6
"isRoot": true,
7
"tokenType": "Border",
8
"path": [],
9
"tokenIds": [
10
"db600240-92cf-11eb-ba3c-1356ef16cb2d"
11
],
12
"subgroups": []
13
},
14
{
15
"id": "e26884bb-0dde-4aa8-99bc-70e667d19940",
16
"name": "Primary Brand Fonts",
17
"description": "",
18
"isRoot": true,
19
"tokenType": "Font",
20
"path": [],
21
"tokenIds": [],
22
"subgroups": []
23
},
24
...
25
]
Copied!
1
ds.allTokenGroups(): [TokenGroup]
Copied!

ds.allTokenGroupTrees

Similarly to ds.allTokenGroups , this function retrieves all token groups defined inside the design system. However, in this case, instead of returning all groups a flat array, it returns trees instead. There will be exactly as many trees in the resulting array as there are token categories (ie. one for colors, one for gradients, and so on).
This function always gets you the root of each category. You can iterate through the tree recursively by using traverse flow, recursive for variant.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all group roots
4
- Iterate through all root groups
5
- For each group, traverse all subgroups
6
- List all subgroups
7
- Note: Alternatively use `traverse` instead of `traverseChildren` to include root groups in the list
8
*}
9
{[ const groups = @ds.allTokenGroupTrees() /]}
10
{[ for rootGroup in groups ]}
11
---
12
{[ traverse rootGroup property subgroups into subgroup ]}
13
{[ if subgroup.isRoot ]}
14
Root Group: {{ subgroup.name }}
15
{[ else ]}
16
- {{ subgroup.path.join("/") }}/{{ subgroup.name }}
17
{[/]}
18
{[/]}
19
{[/]}
20
Copied!
1
[
2
{
3
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363c",
4
"name": "Border",
5
"description": "",
6
"isRoot": true,
7
"tokenType": "Primary Brand Borders",
8
"path": [],
9
"tokenIds": [
10
"db600240-92cf-11eb-ba3c-1356ef16cb2d"
11
],
12
"subgroups": [
13
{
14
"id": "fe1bea60-92cf-11eb-ba3c-1356ef16cb2d",
15
"name": "Most amazing borders there are",
16
"description": "",
17
"isRoot": false,
18
"tokenType": "White Theme",
19
"path": [],
20
"tokenIds": [
21
"f686b140-92cf-11eb-ba3c-1356ef16cb2d"
22
],
23
"subgroups": []
24
}
25
]
26
},
27
{
28
"id": "e26884bb-0dde-4aa8-99bc-70e667d19940",
29
"name": "Font",
30
"description": "",
31
"isRoot": true,
32
"tokenType": "Font",
33
"path": [],
34
"tokenIds": [],
35
"subgroups": []
36
},
37
...
38
]
Copied!
1
ds.allTokenGroupTrees(): [TokenGroup]
Copied!

ds.tokenGroupsOfType

This function retrieves all token groups of one token type as a flat list. The result is the same as with ds.allTokenGroups, but other types than the provided one are filtered out.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch all groups of type "Color"
4
- Iterate through the groups
5
- For each group, fetch the associated token
6
- Iterate through tokens
7
- List token names and associated groups, with their respective type
8
*}
9
{[ const groups = @ds.allTokenGroups() /]}
10
{[ for group in groups ]}
11
{[ const tokens = @ds.tokensByGroupId(group.id) /]}
12
{{ group.name }} ({{ group.tokenType }}):
13
{[ for token in tokens ]}
14
- {{ token.name }}
15
{[/]}
16
17
{[/]}
18
Copied!
1
[
2
{
3
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363c",
4
"name": "Border",
5
"description": "",
6
"isRoot": true,
7
"tokenType": "Border",
8
"path": [],
9
"tokenIds": [
10
"db600240-92cf-11eb-ba3c-1356ef16cb2d"
11
],
12
"subgroups": []
13
}, {
14
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363x",
15
"name": "Colored Borders",
16
"description": "",
17
"isRoot": false,
18
"tokenType": "Border",
19
"path": [],
20
"tokenIds": [
21
"db600240-92cf-11eb-ba3c-1356ef16cb2x"
22
],
23
"subgroups": []
24
}
25
]
Copied!
1
ds.tokenGroupsOfType(tokenType: TokenType): [TokenGroup]
Copied!

ds.tokenGroupTreeByType

Similarly to ds.allTokenGroups , this function retrieves all token groups defined inside the design system for one specific token type. However, in this case, instead of returning all groups a flat array, it returns the root group instead. There is always only one root group per token type, so the result of this call is an object.
You can iterate through the tree recursively by using traverse flow, recursive for variant.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch group root "Color"
4
- Traverse all groups from root
5
- List the group tree
6
*}
7
{[ const group = @ds.tokenGroupTreeByType("Color") /]}
8
9
{[ traverse group property subgroups into subgroup ]}
10
{[ if subgroup.isRoot ]}
11
Root Group: {{ subgroup.name }}
12
{[ else ]}
13
- {{ subgroup.path.join("/") }}/{{ subgroup.name }}
14
{[/]}
15
{[/]}
16
Copied!
1
{
2
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363c",
3
"name": "Border",
4
"description": "",
5
"isRoot": true,
6
"tokenType": "Primary Brand Borders",
7
"path": [],
8
"tokenIds": [
9
"db600240-92cf-11eb-ba3c-1356ef16cb2d"
10
],
11
"subgroups": [
12
{
13
"id": "fe1bea60-92cf-11eb-ba3c-1356ef16cb2d",
14
"name": "Most amazing borders there are",
15
"description": "",
16
"isRoot": false,
17
"tokenType": "White Theme",
18
"path": [],
19
"tokenIds": [
20
"f686b140-92cf-11eb-ba3c-1356ef16cb2d"
21
],
22
"subgroups": []
23
}
24
]
25
}
Copied!
1
ds.tokenGroupTreeByType(tokenType: TokenType): TokenGroup
Copied!
ds.tokenGroupContainingTokenId
This function retrieves the group that directly contains the provided token id. There is always one group that contains one design token. This function is especially useful in injected blueprints, as you don't have to be passing groups with tokens - and can just request them instead.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch token from context - context is property that gets created when you inject something
4
- Fetch group to which it belongs
5
- List all tokens under the same group as the provided token
6
*}
7
8
{[ const token = context.token /]}
9
{[ let group = @ds.tokenGroupContainingTokenId(token.id) /]}
10
11
All tokens similar to fetched token:
12
{[ for token in @ds.tokensByGroupId(group.id) ]}
13
{[ for token in tokens ]}
14
- {{ token.name }}
15
{[/]}
16
{[/]}
Copied!
1
{
2
"id": "22fedcd2-b919-4c3c-b4a8-3265459b363c",
3
"name": "Border",
4
"description": "",
5
"isRoot": true,
6
"tokenType": "Primary Brand Borders",
7
"path": [],
8
"tokenIds": [
9
"db600240-92cf-11eb-ba3c-1356ef16cb2d"
10
],
11
"subgroups": [
12
{
13
"id": "fe1bea60-92cf-11eb-ba3c-1356ef16cb2d",
14
"name": "Most amazing borders there are",
15
"description": "",
16
"isRoot": false,
17
"tokenType": "White Theme",
18
"path": [],
19
"tokenIds": [
20
"f686b140-92cf-11eb-ba3c-1356ef16cb2d"
21
],
22
"subgroups": []
23
}
24
]
25
}
Copied!
1
ds.tokenGroupContainingTokenId(tokenId: string): TokenGroup
Copied!

Design Systems

ds.currentDesignSystem

This function retrieves metadata about the design system which is currently executed. You can use it to enhance exported files with additional information such as the design system name.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch design system we are exporting
4
- List its name inside sentence
5
*}
6
{[ const designSystem = @ds.currentDesignSystem() /]}
7
Currently exporting from {{ designSystem.name }} design system
Copied!
1
{
2
"id": "70",
3
"workspaceId": "20",
4
"name": "Nebula",
5
"description": "Our amazing little design system",
6
"isPublic": false,
7
"basePrefixes": [],
8
"source": {
9
"source": "Figma",
10
"fileId": "123456789123456789",
11
"fileName": "Nebula Design System"
12
}
13
}
Copied!
1
ds.currentDesignSystem(): DesignSystem
Copied!

Design System Versions

ds.currentDesignSystemVersion

This function retrieves the design system version which is currently executed. You can use it to enhance exported files with additional information such as the version name.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch design system we are exporting
4
- Fetch version we are exporting
5
- Use the names inside sentence
6
*}
7
{[ const designSystem = @ds.currentDesignSystem() /]}
8
{[ const version = @ds.currentDesignSystemVersion() /]}
9
Currently exporting from {{ designSystem.name }} design system, version {{ version.version }}
Copied!
1
{
2
"id": "76",
3
"designSystemId": "70",
4
"name": "Shared draft",
5
"description": "",
6
"version": "Shared draft",
7
"changeLog": null,
8
"isReadOnly": false
9
}
Copied!
1
ds.currentDesignSystemVersion(): DesignSystemVersion
Copied!

ds.allDesignSystemVersions

This function retrieves all design system versions for the design system that is being used when exporting. You can, for example, use it to quickly create release notes of the entire design system.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch design system we are exporting
4
- Fetch all its versions
5
- Create a list of published version
6
*}
7
{[ const designSystem = @ds.currentDesignSystem() /]}
8
{[ const versions = @ds.allDesignSystemVersions() /]}
9
Versions for {{ designSystem.name }}:
10
11
{[ for version in versions ]}
12
- {{ version.name }} ({{ version.version }})
13
{[/]}
14
Copied!
1
[{
2
"id": "76",
3
"designSystemId": "70",
4
"name": "Shared draft",
5
"description": "",
6
"version": "Shared draft",
7
"changeLog": null,
8
"isReadOnly": false
9
}, {
10
"id": "90",
11
"designSystemId": "70",
12
"name": "Aurora",
13
"description": "Initial Release",
14
"version": "1.0.0",
15
"changeLog": "Publishing initial stable version of design system",
16
"isReadOnly": false
17
}]
Copied!
1
ds.allDesignSystemVersions(): [DesignSystemVersion]
Copied!

Configuration

configuration

This function retrieves the exporter configuration. You can read more about it in a section dedicated to exporter configuration.
Example Use
Example Payload
Definition
1
{*
2
Following construct will:
3
- Fetch exporter-wide configuration
4
- Use configuration to decide whether to render the menu or not
5
*}
6
{[ if @configuration().showTopMenu ]}
7
<!-- Top menu-->
8
<div class="top-menu">
9
<ul>
10
<li><a href="colors.html" class="selected">Colors</a></li>
11
</ul>
12
</div>
13
{[/]}
14
Copied!
1
{
2
"id": "70",
3
"workspaceId": "20",
4
"name": "Nebula",
5
"description": "Our amazing little design system",
6
"isPublic": false,
7
"basePrefixes": [],
8
"source": {
9
"source": "Figma",
10
"fileId": "123456789123456789",
11
"fileName": "Nebula Design System"
12
}
13
}
Copied!
1
ds.currentDesignSystem(): DesignSystem
Copied!
Last modified 5mo ago