Combine string variables in text layers

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!)? :pray:

10 Likes

i definitely need the answer also

1 Like

Thanks for the feedback!

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

2 Likes

I definitely need this one also. :pray:
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.

3 Likes

Great idea :+1:

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 :pray:

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)

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

i need to have a multiple variables or text

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