In UE5, I am using blueprints to add several elements to a vertical box in a widget. The elements are too big for my purposes, so I shrink them down using a scale box. However, while the scale box makes them fit in the widget, the elements remain the same distance apart as they were when they were big. But since they aren't big, there's a huge gap in between them, causing the elements to still not fit. How can I fix the distance problem?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The big empty strips you are seeing are not “padding” that you can simply remove – they are the space that the Vertical Box still thinks every child needs.
A Scale Box (or a Render-Transform scale) changes only how the widget is drawn.
It does not change the size that the Slate/UMG layout system reserves for that widget, so the panel still allocates the original height and you end up with a gap that is as tall as the old, un-scaled widget.
To make the slots themselves smaller you have to give the layout system a smaller “desired size”.
There are several ways to do that; pick the one that fits your workflow best.
────────────────────────────────────────
Wrap the element in a Size Box (fast & visual-editor friendly)
────────────────────────────────────────
Open the widget that you are inserting into the Vertical Box (or create the wrapper directly in the parent widget).
Add a Size Box above the content.
In the Size Box details panel set
• Width Override (optional)
• Height Override ( ↓ main thing ↓ )
For example Height Override = 64 will make the element report “I’m only 64 px tall”, and that is all the Vertical Box will allocate.
Compile / Save.
Your items are now actually short, so the box stacks them tightly.
Tip: If you want the box to be “at least” a certain size but to grow when the content needs it, use “Min Desired Width/Height” instead of an override.
────────────────────────────────────────
2. Set the element’s slot size rules in code/Blueprint
────────────────────────────────────────
When you add the widget by Blueprint:
────────────────────────────────────────
3. Give the element its own smaller desired size
────────────────────────────────────────
If you own the element’s class you can:
• Reduce padding / margins inside it.
• Put a Size Box as the root and set the overrides there.
• Override NativePreConstruct and call SetMinDesiredHeight, etc.
────────────────────────────────────────
4. Don’t use Scale Box for permanent layout
────────────────────────────────────────
Scale Box (and Render-Transform Scale) is perfect for transient effects (animations, hover effects, DPI scaling), but not for day-to-day layout.
For predictable layout always use Size Box, padding, slot-rules, and/or the “Fill” value on panel slots.
────────────────────────────────────────
Quick checklist
────────────────────────────────────────
☑ Replace / wrap Scale Box with Size Box.
☑ Set Height Override (or Min Desired Height) to the real size you want.
☑ Make sure each slot in the Vertical Box is “Auto” (default) so it uses the child’s desired size.
☑ Remove any extra padding on the slot if you still see a slight gap.
Do that, and the Vertical Box will stack the items tightly with only the space you actually need 👍