Skip to main content

setVariableCodeSyntax

Add or modify a platform definition on codeSyntax. Acceptable platforms are 'WEB', 'ANDROID', and 'iOS'.

Signature

setVariableCodeSyntax(platform: CodeSyntaxPlatform, value: string): void

Remarks

Here’s an example of adding code syntax definitions to a variable:

 const collection = figma.variables.createVariableCollection(
'Example Collection'
)
const variable = figma.variables.createVariable(
'ExampleVariableName',
collection,
'STRING'
)
variable.setVariableCodeSyntax('WEB', 'example-variable-name')
variable.setVariableCodeSyntax('ANDROID', 'exampleVariableName')
variable.setVariableCodeSyntax('iOS', 'exampleVariableName')

// Output:
// {
// WEB: 'example-variable-name',
// ANDROID: 'exampleVariableName',
// iOS: 'exampleVariableName'
// }

console.log(variable.codeSyntax)