How to resize buttons below minimum size

Godot Version

4.6.stable

Question

How do i resize buttons below the minimum size? (I need a button that’s 40x15 but the lowest i can put it is 40x20, even with custom minimum size set to 40x15)

i solved this issue in the discord server. turns out, you have to do some things to the styleboxes. (eg. setting the margins to 0 or -1 pixels)

I don’t think you can.

A button’s minimum size is based on the contents. If you set a custom_minimum_size, that doesn’t mean the button won’t be larger, just that it won’t be smaller. It still has its own “non_custom_minimum_size” that it respects, which may be larger than what you have set.

If you want to resize a button that has text to be smaller than the text, you can enable Button > Text Behavior > Clip Text, although this only seems to work on the x-axis. Alternatively, you can look into Theme Styles, but even there setting the margins to 0 will only get rid of them on the x-axis.

One potential workaround is to have an empty button, to which you parent a Label like so:

This works with Layout > Clip Contents enabled on the Button.

Of course, you could also consider lowering the font size.