Skip to main content
Matteo_Gratton
September 29, 2023

Combine string variables in text layers

  • September 29, 2023
  • 15 replies
  • 4943 views

I was trying to find a way to combine more than one string variable together without the need to create to text layers.

My use case is:

  • I have plenty of small string variables with specific details associated with a main variable mode.
  • I have plenty of variables modes.
  • I need to combine some of the variables together to generate a more complex string.

Current possible solutions (both the solutions are not great for various reasons):

  1. Create 2 text layers and connect them with String Variable A and String Variable B.
    [I need to create an auto-layout frame that contains the 2 layers and resize automatically based on text content and if a variable is empty for any reason]
  2. Create a String Variable C that contains String Variable A and String Variable B.
    [I need to copy and paste the content of both Variables A and B into Variable C. If anything change in time for A or B, I have to change also C]

I’d love to have an option to say: this text layer contains Variable A + Variable B (+ can be also a way to add a space, or a character if needed - like you can do in Prototypes when combine different variables).

What do you think? Am I missing anything and overcomplicating something that already works (I was not able to find it!)? 🙏

15 replies

muh_jad
October 31, 2023

i definitely need the answer also

djv
Figmate
Community Support
November 3, 2023

Thanks for the feedback!

We’ll pass this onto our Variables team for consideration.

Ran_Jakubowicz
January 29, 2024

I definitely need this one also. 🙏
I want to be able to add variables inside text

for example:
Hi {user_name}

would be mega helpful to have a solution for it.

Martin_Mateos_Sanchez
February 24, 2024

Great idea 👍

gemmy
New Member
March 12, 2024

Yes, I need this too. This would be so timesaving to avoid creating slightly different string variables. And please also consider how we can support localisation plural form in one go. Thank you Figma 🙏

April 26, 2024

Also need this as want to put a product name that could change over time across the life of the product - so want to put text either side of a text string variable and can’t work out how to get the auto layout frame to get the text to wrap (breaks it into three parts - text - variable - text)

Marek_Rutkowski
May 17, 2024

I also need to combine multiple fields in one text to wrap things

Marek_Rutkowski
May 17, 2024

i need to have a multiple variables or text

neelts
May 25, 2024

Hi @Matteo_Gratton & @Ran_Jakubowicz, you can achieve this by using my plugin, I made a video with a similar examples on working with strings:

In short, plugin uses code expressions right in the local variables window, so when you refer to other variables they will be updated automatically, so no need to manually update the same thing (you can copy formulas from the video description).

Hope this helps!

Oh, and link to the plugin:
https://www.figma.com/community/plugin/1365339609215368041/dynamic-variables

Steven_Twigg
December 18, 2024

Would really like this feature. It’d help greatly. The workarounds for this cause really big issues in dev handoff.