Variable
Variable properties
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 and prototyping actions, enabling design token functionality and advanced prototyping flows.
id
id: string [readonly]The unique identifier of this variable.
name
name: stringThe name of this variable.
description
description: stringDescription of this variable.
hiddenFromPublishing
hiddenFromPublishing: booleanWhether this variable is hidden when publishing the current file as a library. Can only true if remote is false (e.g. this is a local variable).
getPublishStatusAsync
getPublishStatusAsync(): Promise<PublishStatus>Returns the publishing status of this variable in the current file.
remote
remote: boolean [readonly]Whether this variable is remote or local.
variableCollectionId
variableCollectionId: string [readonly]The ID of the collection that contains this variable.
key
key: string [readonly]The key to use with importVariableByKeyAsync. Note that while this key is present on local and published variables, you can only import variables that are already published.
resolvedType
resolvedType: VariableResolvedDataType [readonly]The resolved type of this variable.
resolveForConsumer
resolveForConsumer(consumer: SceneNode): { value: VariableValue; resolvedType: VariableResolvedDataType }Retrieves the resolved value for this variable if it was bound to consumer.
setValueForMode
setValueForMode(modeId: string, newValue: VariableValue): voidSets the value of this variable for the provided mode. If the modeId belongs to an extended collection, the value will be overridden on the extension.
valuesByMode
valuesByMode: { [modeId: string]: VariableValue } [readonly]The values for each mode of this variable. Note that this will not resolve any aliases. To return fully resolved values in all cases, consider using resolveForConsumer.
remove
remove(): voidRemoves this variable from the document.
scopes
scopes: Array<VariableScope>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.
codeSyntax
codeSyntax: { [platform in CodeSyntaxPlatform]?: string} [readonly]Code syntax definitions for this variable. Supported platforms are 'WEB', 'ANDROID', and 'iOS'.
setVariableCodeSyntax
setVariableCodeSyntax(platform: CodeSyntaxPlatform, value: string): voidAdd or modify a platform definition on codeSyntax. Acceptable platforms are 'WEB', 'ANDROID', and 'iOS'.
removeVariableCodeSyntax
removeVariableCodeSyntax(platform: CodeSyntaxPlatform): voidRemove a platform definition from codeSyntax. Acceptable parameters are 'WEB', 'ANDROID', and 'iOS' if previously defined.
Plugin data properties
getPluginData
getPluginData(key: string): stringRetrieves custom information that was stored on this node or style using setPluginData. If there is no data stored for the provided key, an empty string is returned.
setPluginData
setPluginData(key: string, value: string): voidLets you store custom information on any node or style, private to your plugin. The total size of your entry (pluginId, key, value) cannot exceed 100 kB.
getPluginDataKeys
getPluginDataKeys(): string[]Retrieves a list of all keys stored on this node or style using using setPluginData. This enables iterating through all data stored privately on a node or style by your plugin.
getSharedPluginData
getSharedPluginData(namespace: string, key: string): stringRetrieves custom information that was stored on this node or style using setSharedPluginData. If there is no data stored for the provided namespace and key, an empty string is returned.
setSharedPluginData
setSharedPluginData(namespace: string, key: string, value: string): voidLets you store custom information on any node or style, public to all plugins. The total size of your entry (namespace, key, value) cannot exceed 100 kB.
getSharedPluginDataKeys
getSharedPluginDataKeys(namespace: string): string[]Retrieves a list of all keys stored on this node or style using using setSharedPluginData. This enables iterating through all data stored publicly on a node or style by your plugin.