Egui ui.collapse moves all elements with ui.horizontal

Hey guys using egui over here, using ui.horizontal I have ui.collapse , then I have ui.button

However when I uncollapse it, then it moves the button all the way to the right as shown in the 2nd image.

How do I prevent it from moving all the way to the right, I just want it to stay still.

can you provide the code? the screenshot is useful, but it's much easier if we can also read the code and figure out what's going on.

The button will always be after the space taken by the CollapsingHeader. Space taken is always a rectangle, so the collapsed/hidden part expands it when uncollapsed.

The solution is to put the button in the header of the collapsing widget. Unfortunately CollapsingHeader does not support this as it requires the header to be a string, however you should be able to easily build your own by using CollapsingState, which supports arbitrary widgets for the header.

2 Likes