- Home /
Change width of child in a Vertical Layout Group
I've set up a vertical layout group to keep some buttons arranged and auto-sized. I'd like to have the ability for some buttons to be narrower in width than others, but the vertical layout group forces them to all be expanded to the parent size. What's the simplest way to override this so I can change the width of a specific child element?
The method I used for the image below (so that the last item appears narrower) is that I created an empty child with a horizontal layout group, then I added an empty child panel on the left side with a LayoutElement set to 0.8 Flexible Width to create an empty space, then added the button next to it with another LayoutElement with a 0.2 Flexible Width. This certainly works, but it seems like a lot of added components and empty objects… But perhaps this is the only approach?
Your answer
![](https://koobas.hobune.stream/wayback/20220613173528im_/https://answers.unity.com/themes/thub/images/avi.jpg)