Label

Inherits: Control < CanvasItem < Node < Object

Displays plain text in a line or wrapped inside a rectangle. For formatted text, use RichTextLabel.

Description

Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics, or other formatting. For that, use RichTextLabel instead.

Note: Contrarily to most other Controls, Label's Control.mouse_filter defaults to Control.MOUSE_FILTER_IGNORE (i.e. it doesn't react to mouse input events). This implies that a label won't display any configured Control.hint_tooltip, unless you change its mouse filter.

Note: Unicode characters after 0xffff (such as most emoji) are not supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.

Tutorials

Properties

Align

align

0

bool

autowrap

false

bool

clip_text

false

int

lines_skipped

0

int

max_lines_visible

-1

MouseFilter

mouse_filter

2 (overrides Control)

float

percent_visible

1.0

int

size_flags_vertical

4 (overrides Control)

String

text

""

bool

uppercase

false

VAlign

valign

0

int

visible_characters

-1

Methods

int

get_line_count ( ) const

int

get_line_height ( ) const

int

get_total_character_count ( ) const

int

get_visible_line_count ( ) const

Theme Properties

Color

font_color

Color( 1, 1, 1, 1 )

Color

font_color_shadow

Color( 0, 0, 0, 0 )

Color

font_outline_modulate

Color( 1, 1, 1, 1 )

int

line_spacing

3

int

shadow_as_outline

0

int

shadow_offset_x

1

int

shadow_offset_y

1

Font

font

StyleBox

normal


Enumerations

enum Align:

Align ALIGN_LEFT = 0

Align rows to the left (default).

Align ALIGN_CENTER = 1

Align rows centered.

Align ALIGN_RIGHT = 2

Align rows to the right.

Align ALIGN_FILL = 3

Expand row whitespaces to fit the width.


enum VAlign:

VAlign VALIGN_TOP = 0

Align the whole text to the top.

VAlign VALIGN_CENTER = 1

Align the whole text to the center.

VAlign VALIGN_BOTTOM = 2

Align the whole text to the bottom.

VAlign VALIGN_FILL = 3

Align the whole text by spreading the rows.


Property Descriptions

Align align = 0

  • void set_align ( Align value )

  • Align get_align ( )

Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the Align constants.


bool autowrap = false

  • void set_autowrap ( bool value )

  • bool has_autowrap ( )

If true, wraps the text inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text.


bool clip_text = false

  • void set_clip_text ( bool value )

  • bool is_clipping_text ( )

If true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.


int lines_skipped = 0

  • void set_lines_skipped ( int value )

  • int get_lines_skipped ( )

The node ignores the first lines_skipped lines before it starts to display text.


int max_lines_visible = -1

  • void set_max_lines_visible ( int value )

  • int get_max_lines_visible ( )

Limits the lines of text the node shows on screen.


float percent_visible = 1.0

  • void set_percent_visible ( float value )

  • float get_percent_visible ( )

Limits the amount of visible characters. If you set percent_visible to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.


String text = ""

The text to display on screen.


bool uppercase = false

  • void set_uppercase ( bool value )

  • bool is_uppercase ( )

If true, all the text displays as UPPERCASE.


VAlign valign = 0

Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the VAlign constants.


int visible_characters = -1

  • void set_visible_characters ( int value )

  • int get_visible_characters ( )

Restricts the number of characters to display. Set to -1 to disable.


Method Descriptions

int get_line_count ( ) const

Returns the amount of lines of text the Label has.


int get_line_height ( ) const

Returns the font size in pixels.


int get_total_character_count ( ) const

Returns the total number of printable characters in the text (excluding spaces and newlines).


int get_visible_line_count ( ) const

Returns the number of lines shown. Useful if the Label's height cannot currently display all lines.


Theme Property Descriptions

Color font_color = Color( 1, 1, 1, 1 )

Default text Color of the Label.


Color font_color_shadow = Color( 0, 0, 0, 0 )

Color of the text's shadow effect.


Color font_outline_modulate = Color( 1, 1, 1, 1 )

The tint of Font's outline. See DynamicFont.outline_color.


int line_spacing = 3

Vertical space between lines in multiline Label.


int shadow_as_outline = 0

Boolean value. If set to 1 (true), the shadow will be displayed around the whole text as an outline.


int shadow_offset_x = 1

The horizontal offset of the text's shadow.


int shadow_offset_y = 1

The vertical offset of the text's shadow.


Font font

Font used for the Label's text.


StyleBox normal

Background StyleBox for the Label.