How do I apply a corner radius on a Button node with GradientTexture2D?

Godot Version

4.4

Question

So I’m trying to make a button that has a gradient background. I also want it to have a border and a corner radius applied to all corners of the button.

To try to achieve that, I gave the button a StyleBoxTexture (specifically GradientTexture2D) theme to achieve the gradient background. However, this option did not give me the border or corner radius options, so I tried nesting the button inside of a PanelContainer, and then applied StyleBoxFlat to it. I then changed the PanelContainer’s corner radius and border options, and then checked the “Clip Contents” option in the layout.

But even though the button is nested inside the PanelContainer, the “Clip Contents” option doesn’t get applied to the button. I’m not exactly sure how to approach this problem and would appreciate any help or direction in how to acheive this.

As explained in Control.clip_contents:

Enables whether rendering of CanvasItem based children should be clipped to this control’s rectangle.

If you want to mask children visually you’ll need to change the CanvasItwem.clip_children property.