Godot Version
4.4.1
Question
I’m creating a reusable all-around button family, not using Godot’s built-in one. Inspired by layouts like this:
The idea is simple: all of these are buttons, and inside each button there are element nodes — text, checkbox, options, etc. Where you can press the button and each element changes its state. Theme is handled by Button’s native theme system.
So to implement this I started with:
Button
└── MarginContainer
└── RichTextLabel
And here the problem arises. Button node does not adapt to children size the way containers like MarginContainer do.
One solution was to make Button fully copy the size of MarginContainer — and it does work — but the problem is that whenever anything inside changes, you have to manually tell Button to resize itself. That means manually coding a resize call every time something changes, which is not clean or scalable.
Another solution I considered was:
Container
└── Button (full rect)
└── MarginContainer
└── RichTextLabel
Where the Container owns the sizing naturally, and Button sits inside it as a transparent input-only layer.
In theory this works, but I’m not sure if there are cleaner workarounds to make Button adapt to its children automatically without manual calls.
So what are your thoughts? Is there a clean native way to make Button size from its children? Or is the Container-owns-root approach the right direction?
