See all glossary terms

Stylebox

We use Styleboxes everywhere in Godot to provide styling to UI elements.
They encode things like:
  • background color
  • outline size and outline color
  • rounded corners
  • expand margins: margins projected outside the container (and do not .contribute to its size)
  • content margins: iternal margins between the elements and its contents
  • drop shadow
  • texture
There are a few different Styleboxes:
  • StyleBoxFlat: Draws a background color, with an optional outline. It's the most frequently used StyleBox.
  • StyleBoxTexture: Draws a texture without stretching the sides. This makes it possible to use images to create complicated borders. The texture can be stretched and the sides will remain unstretched thanks to 9-slice scaling.
  • StyleBoxLine: Displays a single line of a given color and thickness. It's mainly used for separators.
  • StyleBoxEmpty: Draws nothing. It's used to disable potential styles that get added on top of existing styles. For example, the focus style is often by default an outline that is drawn on top of the normal style. If you wanted nothing instead, you can use a StyleBoxEmpty.
While StyleBoxes are mostly used for UI, they are not directly related to UI. In theory, you could use the image a stylebox produces as a texture to use anywhere.

See Also

Related terms in the Glossary