From my experience, it’s directly impossible - Button extends Control, so if you add anything inside, it will never display properly.
I wanted to ask what is the most reasonable approach to solving it. Because it seems there are many ways, including making entirely new control type, but perhaps there is easy and straightforward way of doing it. You can get the same results using PanelContainer and HBoxContainer in less than a minute, but of course it’s not going to be clickable.
If layout fights, do the PanelContainer version and make it clickable:
PanelContainer + HBoxContainer for the look
either put a full-rect flat Button behind/over it (mouse_filter set so clicks hit the button), or extend BaseButton and build the same content as children
I don’t know how much it affects this, but I have a set of such buttons in VBoxContainer. It basically displays a list of 1 pixel height Buttons, and content of the Button is outside below it. Contents of the Buttons are also on top of each other. Basically what I’ve said - Button is not Container, so it goes completely bonkers and doesn’t know how to display.
PanelContainer approach might work, but is it possible to have all custom states for it like for Button? I mean normal/hover/focused etc.
After some testing I’ve realized that for my use case 4 columns is too much (doesn’t look that good), so I had to cut 2 columns. And that means I can just use Icon and Text without building custom columns. But if someone knows how to do it right I will be sure to mark it as solution.
I believe there should be a ButtonContainer node in the future, for now using MarginContainer to enforce same-sized control nodes is a pretty common work around
Yup, Button won’t size to its children, so in a Vbox you get that 1px tall mess. That’s expected. For custom content + real button stales, don’t fake it with a plain PanelContainer. Use BaseButton ,or a Button with empty text, as the root and put the HBox inside. Hover/pressed/focus still come from the button theme styles
Set a custom_minimum_size on the button or make the Hbox drive it via min sizes on the kids, so the VBox gets a real height. Since you cut it down to icon + text tho, the built-in Button icon/text is the right choice for me, no custom layout needed tho