Xylos brands

PowerApps: how to automatically adjust the text box

You’re probably familiar with the AutoHeight property in PowerApps. Unfortunately, the Text Input control doesn’t include this property, which means you have to work with a vertical scroll bar – and sometimes, you just need to be able to view your entire text at once. So, is there a way to automatically adjust the size of the text box?

If you play it smart, you can mimic this property, so that the text box doesn’t clog up unnecessary screen space and expands as needed.

How do I do this?

For instance: if a new line starts after every 23 characters and my lines are 34 mm high, then the formula is as follows:

Height = 34 mm x (no. of words / 23)

In PowerApps Syntax, this becomes:

Height =    34    * (RoundUp(Len(TextInput1.Text),0 / 23))

What does this formula mean?

  • 34 is the desired line height. In this example, the value is 34 mm.
  • RoundUp function rounds up the number if the result is a fraction.
  • Len function counts the number of characters in a string.
  • The string’s content is described in TextInput1.Text control.
  • The number 0 indicates the amount of decimal places.
  • 23 indicates the number of characters per line.

Not convinced yet?
Give it a try!

Looking for training tailored to the needs of your company? Contact my colleagues in our Learning Team for more information.

Share this blogpost

Also interesting for you


Brett R

Thanks for this, I slightly modified so that it doesn't slowly grow each character, but only grows by 40 pixels every time you add more than 90 characters.

The 0.01 is so if you have NO text in the box, it still is at least 40px high :)

40 * RoundUp((Len(txt_Section1Answer_6.Text)+0.01) / 90,0)


Thanks to both of you! Not what I was looking for when I found it but still super duper helpful!

Sam G

Here's my version. It looks for lengths of characters without a newline and also for newlines (which aren't accounted for above). Can be placed directly into the height field for the form element.

48 + ((CountRows(MatchAll(Self.Text, "[^\n]{100}").FullMatch) + CountRows(MatchAll(Self.Text, "\n").FullMatch))*16)

48 = start height
100 = max number of characters per line before adding to height
16 = amount to add to height per line or newline

Leave a reply

Your email address will not be published. Required fields are marked.