Loading...

How to make a auto-height textinput component for Power Apps

How to make a auto-height textinput component for Power Apps

Some controls in Power Apps do not have an auto height property, which means that we can’t get the Height of a control to automagically adjust to its content. Especially for the textinput control, this is a real bummer, as we a user’s input a pretty much unpredictable. On the one hand, we do not want to waste precious screen estate by making the box as big as possible, on the other hand, a too small box will result in an ugly scrollbar that no one want to see.

auto height textinput component

Build a component with me

If you follow my blog posts then you might know that I love to componentize everything that I’d like to use again, and an auto-height textinput seems to tick that box as well.

  1. Open make.powerapps.com
  2. Create a new component cmp_textinput
  3. Create a custom input property outsideMargin (Number), 20 - determines the margin around the component
  4. Create a custom output property userText (Text), txt_userInput.Text so that we can pass this value back to our app

Make magic work

  1. Insert a text label lbl_autoHeightHelper and a textinput txt_userInput
  2. Make sure that the textinput sits on top
  3. Set the Mode of the textinput to Multiline
  4. Set the X and Y of the textinput to cmp_textinput.outsideMargin
  5. Set the Width of the textinput to cmp_textinput.Width-2*cmp_textinput.outsideMargin - this makes sure, that when you horizontally resize the component, this also applies to the textinput as well
  6. Set Height of the textinput to Max(42, lbl_autoHeightHelper.Height)
  7. Set the Text of the text label to txt_userInput1.Text
  8. Set X of the text label to txt_userInput1.X and Y to txt_userInput1.Y
  9. Set Width of the text label to txt_userInput1.Width
  10. Set the Height of the text label to cmp_textinput.Height-2*cmp_textinput.outsideMargin
  11. Set the auto height of the text label to true
  12. Set the Color of the text label to Transparent
  13. For the text label, set Font to txt_userinput.Font, FontWeight to txt_userinput.FontWeight, and Size to txt_userinput.Size
  14. Set the Width of the textlabel to txt_userInput.Width and the Height to Max(42, lbl_autoHeightHelper.Height)

Understand the magic

  1. We utilize the auto height property of the text label and hook it to the Height property of the text input. The text label will get exactly the text in the Font, Size, FontWeight of the textinput, but as we set the Color to Transparent, it won’t show up.
  2. For the Width of the text input, we reference the width of the component itself so that we can make the textinput as wide as necessary by adjusting the size of the component instance in an app
  3. The Max(42, lbl_autoHeightHelper.Height) for the Height of the textinput ensures that we always have 42 as a minimum Height and the Height of the text label (which has auto height enabled) as maximum Height

Feedback and what’s next

That’s it!

a little hack to bring auto-height to controls that don’t come with it out of the box. Let me know what you think on twitter.

Maybe you could spot in the screenshot above, that I added some more cool features to my component, such as a trailing icon (delete, error), a label, an asterisk. a helper and an error text, and an indicator of how many characters are still left. This is a sweet sneak preview on a Material design component library that I am building together with my dear friend and partner in crime Robin Rosengrün.

If you want to know more about it and/or you found this blog post useful, please also subscribe to my newsletter - news coming about every 2 months, I promise to not spam you!

Published on:

Learn more
Need help with this product?

We can help you with How to make a auto-height textinput component for Power Apps

If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.

Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

You are holding GitHub Copilot Wrong!

Most developers think that one can’t really use GitHub Copilot wrong. There is a chat interface that lets you also choose a model, so th...

8 months ago

You are holding GitHub Copilot Wrong!

Part 0 showed why constant prompting, re-prompting, and steering GitHub Copilot feels fragile. Not because Copilot is unreliable, but because ...

8 months ago

Building a Multi-Hierarchy Ticket Classification System (Because Keywords Aren't Enough)

Look, I love a good keyword-based system as much as the next developer. They’re fast, predictable, and when your user says “VPN,&r...

8 months ago

Secretless cross-tenant dataverse access

Client secrets are like hiding your house key under the mat; easy to grab and impossible to audit. Certificates are just slightly better, beca...

10 months ago

How Azure CLI handles your tokens and what you might be ignoring

Running az login feels like magic. A browser pops up, you pick an account, and from then on, everything just works. No more passwords, no more...

10 months ago

How Dev Proxy teaches you to make your apps more resilient

I added Microsoft Dev Proxy to my Mermaid → Dataverse converter, because I wanted to test how it handled rate limits and API errors. What I go...

10 months ago

Building Azure functions that never store secrets — ever

What if your function could hit Microsoft Graph with no client secrets, no certs, and no Key Vault entries? That is exactly what a Managed id...

11 months ago

Introducing Mermaid to Dataverse Converter

Why diagrams matter (and why they usually fail us) Entity-Relationship Diagrams (ERDs) are the universal shorthand for talking about data mode...

11 months ago

It’s OK to be seen trying

It’s OK to be seen trying Somewhere along the way, we started believing that you’re only allowed to speak after you’ve figured everything out....

1 year ago

Stuck in pilot - Part 1: no foundations, no future

“We just need to test the AI. We’ll figure out the data later.” That sentence has quietly killed more AI pilots than any model failure ever ...

1 year ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.