I have some custom property drawers written in IMGUI and I would like to adapt them to UI Toolkit. Here is one of them. It adds a button to the right edge of the property field:
I find using the UI Toolkit debugger is a great way to experiment quickly with styles when you are unsure. Open up the debugger and select your element, you will then be able to adjust the styles. Experiment to see what needs to be changed to fit what you need and then make those changes permanent in code or with a style sheet,
Thank you for your assistance. The problem indeed lied in flex grow-shrink modifiers, but I should have applied them not to the container but to its children: the property field and the button:
// Allowing property to automatically adjust its width
IStyle propertyStyle = propertyField.style;
propertyStyle.flexGrow = new StyleFloat(1f);
propertyStyle.flexShrink = new StyleFloat(1f);
// Making button fixed-sized
IStyle buttonStyle = button.style;
buttonStyle.flexGrow = new StyleFloat(0f);
buttonStyle.flexShrink = new StyleFloat(0f);