As the title says, I am interested in making some of my text labels have responsive control width's depending on the length of text within them. I am using a function on the Fill property and it would look a lot better if the control it fills is only as long as the text of the selection made.
What would this width property function look like, is this even possible?
Need to expand width in textinput based on texinput words in power apps
Makes total sense, and I agree that does fit pretty darn well. I'm gonna use this but also just got this to work.
If(Len(Self.Text)>45, 500, (If(Len(Self.Text)*100<100,100,Len(Self.Text)*9)))
This is doing a good job first regulating my items that are super long, but then be kind to the shorter item names. Apologies if it sounds like I'm not listening (I am! haha) because I still have the *100 in there, but I think this meets the best of both worlds.
Thank you so much for these functions, this is such an awesome transferable function to understand!
Sean
There's too many issues with what you changed to combine them honestly
For Example
In
If(Len(Self.Text)*100<100,100,Len(Self.Text)*12)
Len(Self.Text)*100 - With this, even ten characters in a text box is going to be checking against a value of 1000, thats a massive number to chekc against for a 10 character string, very inaccurate.
and in the second half
If(Len(Self.Text)*0<300
Len(Self.Text)*0 will never have any other value than 0, so it will always come out as true, and therefore give you a width of 500 every single time.
Here you will see I shortened short side a little for you , and brought down full size a bit
If(Len(Self.Text)*10<75,75,Len(Self.Text)*8.5)
and here are several examples from 5 digits up to 100 to show it looks good with just this
@TheRobRush Okay to add onto my previous reply, I just found this works really well for the short text. How can I combine these two together to manage the min's and max's out there.
Short Text -
If(Len(Self.Text)*100<100,100,Len(Self.Text)*12)
Long Text -
If(Len(Self.Text)*0<300,500,Len(Self.Text)*5)
What I originally wrote already does account for short text,
If(Len(Self.Text)*10<100,100,Len(Self.Text)*10)
First portion, If Len(Self.Text) < 100, means if this text formula is shorter then 100 give it a minimum width of 100, can change that 100 to whatever works for you.
The way you have changed it to
If(Len(Self.Text)*0<300
should always return to you a 500 width box since ANY number multiplied by 0 will always be less than 300.
Hi Rob, this is really cool, I've been playing with it and this works really well for the long item names.
If(Len(Self.Text)*0<300,500,Len(Self.Text)*5)
However, when item names are shorter than these specs, the formula doesn't apply well and makes for a wide box. I've been trying to make an Or, ||, && addition to the function but I'm clearly doing it wrong because nothing beyond the original function has an effect.
Would you be able to help define what this function would look like if it took into consideration text that is both very long and shorter than the pre-defined measures? I hope that makes sense... 🙂
You would need to do something similar to this with a text box's width property
If(Len(Self.Text)<100,
320,
Len(Self.Text)<200,
440,
Len(Self.Text)<300,
540,
640)
Or even work out a mathematical formula based on len and how large you made your font for example
If(Len(Self.Text)*10<100,100,Len(Self.Text)*10)
Seems to work pretty well for Open Sans 13
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional