Skip to main content
Alex_FG
New Participant
Sep 1, 2023 4:20 AM UTC
Solved

Is it not possible to set a text variable to an empty string?

I can set it to ’ ’ (a space), or any string with text in it, but nothing happens if the value I give it is ‘’.

This topic has been closed for replies.
Alex_FG
Alex_FGSolution
New Participant
Sep 5, 2023 9:42 AM UTC

I think I was setting it to null instead of ‘’. Setting it to ‘’ worked.

11 replies

tank666
Nov 4, 2024 3:06 PM UTC
const collection = figma.variables.createVariableCollection('New collection'),
    modeId = collection.defaultModeId,
    variable = figma.variables.createVariable('New string variable', collection, 'STRING');

variable.setValueForMode(modeId, '');

This code will create a new collection with a variable with an empty value.

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank