# How to auto adjust text+image widget to fit variable text content?

**URL:** <https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375>\
**Category:** UI\
**Tags:** size, textbox, unreal-engine, Widget, UE4, question, UMG\
**Created:** [June 25, 2021, 8:27pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375 "2021-06-25T20:27:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ssteidle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ssteidle](https://forums.unrealengine.com/u/Ssteidle)\
**Post date:** [June 25, 2021, 8:27pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/1 "2021-06-25T20:27:08Z")

</div>

Hi, I am not a pro at UE4 - I’ve read lots of different similar Q+A’s and experimented endlessly without success.

My goal:

- Have a text widget pop up upon clicking, and ensure that the text widget automatically enlarges to fit all the text that is input to the component.
- I also have an image in the widget that serves as a backdrop, and I want this to also enlarge so it always frames the text.

Photos are attached. After no luck with Scale Box nor Size Box, I tried placing both Image and Text into a Grid Panel and ticking “size to content” for the grid panel, but you’ll notice that it doesn’t grow enough in size when I type in a lot of text.

#headache. _THANK YOU FOR YOUR HELP_

 ![342426-screen-shot-2021-06-25-at-31932-pm.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/d/08d5318addb321619cceafac861dd834295804e7.png)

![342427-screen-shot-2021-06-25-at-32001-pm.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/3/b631ec22b94a3a1541bacc1e638f8214a269c65f.png)

 ![342428-screen-shot-2021-06-25-at-32021-pm.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/5/97515d7e4dd2afb9091d625455e98b0b46d82026.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 25, 2021, 9:16pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/2 "2021-06-25T21:16:24Z")

</div>

This can be done but one thing is unclear.

> ensure that the text widget  
> automatically enlarges to fit all the  
> text that is input to the component.

How are you going to handle horizontal size? What are the rules? When are wrapping to the next line? Is this value fixed or dynamic?

As in:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/5/5/d55faa9be46c1b4be7093bdf26cfdabef0aa7606.gif)](https://gyazo.com/63ee952d963c487adf851837f7e6489d)

What would be the desired size? Are we expanding only in vertically or also horizontally?

---

<div class="post-metadata">

**Author:** ![Ssteidle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ssteidle](https://forums.unrealengine.com/u/Ssteidle)\
**Post date:** [June 25, 2021, 9:20pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/3 "2021-06-25T21:20:04Z")

</div>

I want it to expand vertically. In the example photo you’ll see I (think in the past) set a maximum bound for horizontal length

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 25, 2021, 9:33pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/4 "2021-06-25T21:33:57Z")

</div>

![342435-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/f/6df4f51ec03734030937d777265fc59b85cdbccc.png)

- ensure the outer element that should respect the size of the text is sitting in the canvas and is flagged as _Size To Content_
- ctrl+shift click middle anchor from the dropdown for that element - this will anchor it in the middle of the canvas

* * *

![342438-screenshot-6.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/0/9/d09547e6488b83b838e6ceab8d8e4061a77a7d4a.png)

- select the desired wrap size for the text - that’s your max horizontal size
- ensure auto wrap is off
- try to ignore the way it looks in preview - there’s been no layout pre-pass so it _may_ look funky at this stage

* * *

- flag the widget component to respect the Desired Size the text box dictates:

 ![342437-screenshot-5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/8/0c84464d445e769667793e4a71bb6ef3fd596036.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 25, 2021, 9:42pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/5 "2021-06-25T21:42:54Z")

</div>

So text wrapped to 256px should look like so:

[![Image from Gyazo](https://i.gyazo.com/1e7336e05feb46be2981d5a0b87f2a7a.gif)](https://gyazo.com/1e7336e05feb46be2981d5a0b87f2a7a)

---

<div class="post-metadata">

**Author:** ![Ssteidle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ssteidle](https://forums.unrealengine.com/u/Ssteidle)\
**Post date:** [June 25, 2021, 9:43pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/6 "2021-06-25T21:43:21Z")

</div>

😃 !! The “Draw at Desired Size” = CRUCIAL.

Thank you!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 25, 2021, 9:47pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/7 "2021-06-25T21:47:52Z")

</div>

Now, Draw at Desired Size is somewhat computationally intensive. If you update text once, it’s absolutely fine. If you print it letter by letter, it’s also fine since you’ll be doing it to 1 widget at a time, most likely.

If you want to update it _every frame_ (perhaps you’re doing something funky and animated with the text) to many widgets, it will get costly.

---

<div class="post-metadata">

**Author:** ![Ssteidle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ssteidle](https://forums.unrealengine.com/u/Ssteidle)\
**Post date:** [June 25, 2021, 9:56pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/8 "2021-06-25T21:56:50Z")

</div>

Ok, hmm, good to know. What I imagine is that I will have roughly 10-15 of these in my game. Each will have it’s own static message (this is an informational tour), so the user is not interacting with the widget or changing its input. Is that computationally burdensome?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 25, 2021, 10:10pm UTC](https://forums.unrealengine.com/t/how-to-auto-adjust-text-image-widget-to-fit-variable-text-content/485375/9 "2021-06-25T22:10:15Z")

</div>

Nah, that’s more that fine.
