A themed button that can contain text and an icon.
[Button] is the standard themed button. It can contain text and an icon, and it will display them according to the current [Theme]. [b]Example:[/b] Create a button and connect a method that will be called when the button is pressed: [codeblocks] [gdscript] func _ready(): var button = Button.new() button.text = "Click me" button.pressed.connect(_button_pressed) add_child(button)

func _button_pressed(): print("Hello world!") [/gdscript] [csharp] public override void _Ready() { var button = new Button(); button.Text = "Click me"; button.Pressed += ButtonPressed; AddChild(button); }

private void ButtonPressed() { GD.Print("Hello world!"); } [/csharp] [/codeblocks] See also [BaseButton] which contains common properties and methods associated with this node. [b]Note:[/b] Buttons do not detect touch input and therefore don't support multitouch, since mouse emulation can only press one button at a given time. Use [TouchScreenButton] for buttons that trigger gameplay movement or actions.
https://godotengine.org/asset-library/asset/2712 https://godotengine.org/asset-library/asset/2789
- Text alignment policy for the button's text.
- If set to something other than [constant TextServer.AUTOWRAP_OFF], the text gets wrapped inside the node's bounding rectangle.
- Autowrap space trimming flags. See [constant TextServer.BREAK_TRIM_START_EDGE_SPACES] and [constant TextServer.BREAK_TRIM_END_EDGE_SPACES] for more info.
- If [code]true[/code], text that is too large to fit the button is clipped horizontally. If [code]false[/code], the button will always be wide enough to hold the text. The text is not vertically clipped, and the button's height is not affected by this property.
- When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect. See also [theme_item icon_max_width].
- Flat buttons don't display decoration.
- Button's icon, if text is present the icon will be placed before the text. To edit margin and spacing of the icon, use [theme_item h_separation] theme property and [code]content_margin_*[/code] properties of the used [StyleBox]es.
- Specifies if the icon should be aligned horizontally to the left, right, or center of a button. Uses the same [enum HorizontalAlignment] constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.
- Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
- The button's text that will be displayed inside the button's area.
- Base text writing direction.
- Sets the clipping behavior when the text exceeds the node's bounding rectangle.
- Specifies if the icon should be aligned vertically to the top, bottom, or center of a button. Uses the same [enum VerticalAlignment] constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.
Default text [Color] of the [Button].
Text [Color] used when the [Button] is disabled.
Text [Color] used when the [Button] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.
Text [Color] used when the [Button] is being hovered.
Text [Color] used when the [Button] is being hovered and pressed.
The tint of text outline of the [Button].
Text [Color] used when the [Button] is being pressed.
Icon modulate [Color] used when the [Button] is disabled.
Icon modulate [Color] used when the [Button] is focused. Only replaces the normal modulate color of the button. Disabled, hovered, and pressed states take precedence over this color.
Icon modulate [Color] used when the [Button] is being hovered.
Icon modulate [Color] used when the [Button] is being hovered and pressed.
Default icon modulate [Color] of the [Button].
Icon modulate [Color] used when the [Button] is being pressed.
This constant acts as a boolean. If [code]true[/code], the minimum size of the button and text/icon alignment is always based on the largest stylebox margins, otherwise it's based on the current button state stylebox margins.
The horizontal space between [Button]'s icon and text. Negative values will be treated as [code]0[/code] when used.
The maximum allowed width of the [Button]'s icon. This limit is applied on top of the default size of the icon, or its expanded size if [member expand_icon] is [code]true[/code]. The height is adjusted according to the icon's ratio. If the button has additional icons (e.g. [CheckBox]), they will also be limited.
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
The size of the text outline. [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
[Font] of the [Button]'s text.
Font size of the [Button]'s text.
Default icon for the [Button]. Appears only if [member icon] is not assigned.
[StyleBox] used when the [Button] is disabled.
[StyleBox] used when the [Button] is disabled (for right-to-left layouts).
[StyleBox] used when the [Button] is focused. The [theme_item focus] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
[StyleBox] used when the [Button] is being hovered.
[StyleBox] used when the [Button] is being hovered (for right-to-left layouts).
[StyleBox] used when the [Button] is being pressed and hovered at the same time.
[StyleBox] used when the [Button] is being pressed and hovered at the same time (for right-to-left layouts).
Default [StyleBox] for the [Button].
Default [StyleBox] for the [Button] (for right-to-left layouts).
[StyleBox] used when the [Button] is being pressed.
[StyleBox] used when the [Button] is being pressed (for right-to-left layouts).