Forum Discussion

Vic's avatar
Vic
Community Member
4 months ago

Automatically resize text box to fit text variables?

Hello.

Has anyone discovered a way to get a text box to dynamically resize to fit the length of a text variable? The text box in question is coloured with an outline and drop shadow and needs to hug the text with even margins. The variable is between 20 and 200 words.

With 'adjust height to fit text' selected, the text shrinks to fit the box rather than the box expanding to fit the text. 

If I oversize the text-box, the text stays the correct size but I end up with massive top/bottom margins on the shorter strings which made our visual designer exclaim "Eeek, no!"

I have tried using a separate rectangle and resizing it using JavaScript (using string length of the variable to roughly calculate the height) but the outline and drop shadow on the text box get stretched (A second "Eeek!" was heard at this point).

Do I need to draw my own rectangles using JavaScript or is there a better way? Am I missing something really obvious? It seems weird that this is so difficult to do!

Thanks!

3 Replies

    • Vic's avatar
      Vic
      Community Member

      Hi KellyAuner​ This does not work if the text is a variable. It makes the height the size of the initial variable value and then makes the variable text smaller to fit if the variable is longer than the initial value. If the variable is longer than the initial value it gives it big margins instead of adjusting the height.

      • Hi Vic​!

        Thanks for clarifying!

        That's correct. With Variable Text, the “Expand height” auto-fit option behaves differently than with static text. Currently, Storyline does not support dynamically resizing a Text Box to match the changing length of a Variable while keeping margins, outline, and shadows consistent. I do understand having this level of functionality could improve your authoring experience. I've shared this feedback with our product team!

        We have a lot of Javascript gurus here in the community. I'm hopeful they can share custom design solutions that worked for them!