Skip to main content

Is there a method for setting/assigning a range of text to a variable? I noticed that even the setRangeBoundVariable(start, end, type, variableId) doesn’t support “color” for the type.


Something like:


figma.currentPage.selectione0].setRangeBoundVariable(0, 5, 'color', 'VariableID:313:879')

Which would then apply that variable to text characters 0-5.

Text color is managed in the fills property, so you need to use setRangeFills:


figma.currentPage.selection[0].setRangeFills(
0,
5,
[
{
type: 'SOLID',
color: { r: 0, g: 0, b: 0 },
boundVariables: { color: { type: 'VARIABLE_ALIAS', id: 'VariableID:2:5' } }
}
]
)

Yessss! That totally worked. Thank you!


Reply