How to expand VisualElement to the size of its content?

Hello,
I’d like to know how is it possible to make VisualElement to expand to the size of its content, or shrink back if the content is smaller? The element has an absolute position. Is it possible to be done with style settingor I have to write it manually?

The source of the element (just in case)

If the children (icons inside container) are set as style.position = Position.Relative it should automatically resize to fit them.

It’s okay if the parent is absolute. But when you set children to Position.Absolute it will no longer flex (adjust) to contain them. I suspect you likely have the children as Absolute or otherwise this should happen automatically.

You are right, thanks! The problem was I set the height of the parent panel. Once I changed it to “auto” the panel started stretching