Skip to main content
Alex_FG
New Participant
September 1, 2023
Solved

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

  • September 1, 2023
  • 11 replies
  • 3775 views

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.
Best answer by Alex_FG

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

11 replies

Alex_FG
Alex_FGAuthor
New Participant
September 1, 2023

nvm it’s a bug on my end 🤓

September 5, 2023

Hey! How did you fixed it? I have the same problem 😦

Alex_FG
Alex_FGAuthorSolution
New Participant
September 5, 2023

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

Martin_Mateos_Sanchez
January 6, 2024

Hello! Which ASCII character are you referring to as ‘’? Right now, I can only set it to a whitespace for the variable to appear as empty (although it isn’t, since it’s a whitespace and has a length of one)
Captura de pantalla 2024-01-06 172436

tank666
January 6, 2024

You need to set it to an empty string without any character.

variable = '';
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
Martin_Mateos_Sanchez
January 6, 2024

Oh, is that using the API? Or is there a way using the keyboard? Because if the variable is set to a whitespace and I delete it and press intro, the variable resets to the whitespace. Similarly, if I create a new text variable, which by default is set to “String value” and I try to delete that completely and press intro, the variable resets to “String value”

So weird

tank666
January 6, 2024

Only using the Plugin API. I wrote about it here:

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
May 6, 2024

Hey, I am not able to do it. Can you explain it a bit more ? How do I set a string’s value as null

tank666
May 6, 2024

You cannot set null as a value for a string variable. Instead of null, you must specify an empty string.

variable.setValueForMode(modeId, '')
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
Joseph_Kaguri
New Member
July 18, 2024

Hi, could you share the full code that you added on Run plugin API to set a String variable empty?