Table of Contents

Class TabBar

A control that provides a horizontal bar with tabs.

Inheritance
TabBar

Remarks

A control that provides a horizontal bar with tabs. Similar to TabContainer but is only in charge of drawing tabs, not interacting with children.

Properties

clip_tabs

If true, tabs overflowing this node's width will be hidden, displaying two navigation buttons instead. Otherwise, this node's minimum size is updated so that all tabs are visible.

var clip_tabs : bool = true

Property Value

bool

Remarks

  • void set_clip_tabs(bool value)
  • bool get_clip_tabs

current_tab

The index of the current selected tab. A value of -1 means that no tab is selected and can only be set when deselect_enabled is true or if all tabs are hidden or disabled.

var current_tab : int = -1

Property Value

int

Remarks

  • void set_current_tab(int value)
  • int get_current_tab

deselect_enabled

If true, all tabs can be deselected so that no tab is selected. Click on the current tab to deselect it.

var deselect_enabled : bool = false

Property Value

bool

Remarks

  • void set_deselect_enabled(bool value)
  • bool get_deselect_enabled

drag_to_rearrange_enabled

If true, tabs can be rearranged with mouse drag.

var drag_to_rearrange_enabled : bool = false

Property Value

bool

Remarks

  • void set_drag_to_rearrange_enabled(bool value)
  • bool get_drag_to_rearrange_enabled

max_tab_width

Sets the maximum width which all tabs should be limited to. Unlimited if set to 0.

var max_tab_width : int = 0

Property Value

int

Remarks

  • void set_max_tab_width(int value)
  • int get_max_tab_width

scroll_to_selected

If true, the tab offset will be changed to keep the currently selected tab visible.

var scroll_to_selected : bool = true

Property Value

bool

Remarks

  • void set_scroll_to_selected(bool value)
  • bool get_scroll_to_selected

scrolling_enabled

if true, the mouse's scroll wheel can be used to navigate the scroll view.

var scrolling_enabled : bool = true

Property Value

bool

Remarks

  • void set_scrolling_enabled(bool value)
  • bool get_scrolling_enabled

select_with_rmb

If true, enables selecting a tab with the right mouse button.

var select_with_rmb : bool = false

Property Value

bool

Remarks

  • void set_select_with_rmb(bool value)
  • bool get_select_with_rmb

tab_alignment

Sets the position at which tabs will be placed. See AlignmentMode for details.

var tab_alignment : int = 0

Property Value

int

Remarks

  • void set_tab_alignment(int value)
  • int get_tab_alignment

tab_close_display_policy

Sets when the close button will appear on the tabs. See CloseButtonDisplayPolicy for details.

var tab_close_display_policy : int = 0

Property Value

int

Remarks

  • void set_tab_close_display_policy(int value)
  • int get_tab_close_display_policy

tab_count

The number of tabs currently in the bar.

var tab_count : int = 0

Property Value

int

Remarks

  • void set_tab_count(int value)
  • int get_tab_count

tabs_rearrange_group

TabBars with the same rearrange group ID will allow dragging the tabs between them. Enable drag with drag_to_rearrange_enabled.

Setting this to -1 will disable rearranging between TabBars.

var tabs_rearrange_group : int = -1

Property Value

int

Remarks

  • void set_tabs_rearrange_group(int value)
  • int get_tabs_rearrange_group

drop_mark_color

Theme Property

Modulation color for the drop_mark icon.

 = ``Color(1, 1, 1, 1)``

Property Value

Color

font_disabled_color

Theme Property

Font color of disabled tabs.

 = ``Color(0.875, 0.875, 0.875, 0.5)``

Property Value

Color

font_hovered_color

Theme Property

Font color of the currently hovered tab. Does not apply to the selected tab.

 = ``Color(0.95, 0.95, 0.95, 1)``

Property Value

Color

font_outline_color

Theme Property

The tint of text outline of the tab name.

 = ``Color(0, 0, 0, 1)``

Property Value

Color

font_selected_color

Theme Property

Font color of the currently selected tab.

 = ``Color(0.95, 0.95, 0.95, 1)``

Property Value

Color

font_unselected_color

Theme Property

Font color of the other, unselected tabs.

 = ``Color(0.7, 0.7, 0.7, 1)``

Property Value

Color

h_separation

Theme Property

The horizontal separation between the elements inside tabs.

 = ``4``

Property Value

int

icon_max_width

Theme Property

The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with TabBar.set_tab_icon_max_width. The height is adjusted according to the icon's ratio.

 = ``0``

Property Value

int

outline_size

Theme Property

The size of the tab text outline.

Note: If using a font with multichannel_signed_distance_field enabled, its msdf_pixel_range must be set to at least twice the value of outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.

 = ``0``

Property Value

int

font

Theme Property

The font used to draw tab names.

Font font

Property Value

Font

font_size

Theme Property

Font size of the tab names.

int font_size

Property Value

int

close

Theme Property

The icon for the close button (see tab_close_display_policy).

Texture2D close

Property Value

Texture2D

decrement

Theme Property

Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent.

Texture2D decrement

Property Value

Texture2D

decrement_highlight

Theme Property

Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.

Texture2D decrement_highlight

Property Value

Texture2D

drop_mark

Theme Property

Icon shown to indicate where a dragged tab is gonna be dropped (see drag_to_rearrange_enabled).

Texture2D drop_mark

Property Value

Texture2D

increment

Theme Property

Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent.

Texture2D increment

Property Value

Texture2D

increment_highlight

Theme Property

Icon for the right arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.

Texture2D increment_highlight

Property Value

Texture2D

button_highlight

Theme Property

Background of the tab and close buttons when they're being hovered with the cursor.

StyleBox button_highlight

Property Value

StyleBox

button_pressed

Theme Property

Background of the tab and close buttons when it's being pressed.

StyleBox button_pressed

Property Value

StyleBox

tab_disabled

Theme Property

The style of disabled tabs.

StyleBox tab_disabled

Property Value

StyleBox

tab_focus

Theme Property

StyleBox used when the TabBar is focused. The tab_focus StyleBox is displayed over the base StyleBox of the selected tab, 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 tab_focus

Property Value

StyleBox

tab_hovered

Theme Property

The style of the currently hovered tab. Does not apply to the selected tab.

Note: This style will be drawn with the same width as tab_unselected at minimum.

StyleBox tab_hovered

Property Value

StyleBox

tab_selected

Theme Property

The style of the currently selected tab.

StyleBox tab_selected

Property Value

StyleBox

tab_unselected

Theme Property

The style of the other, unselected tabs.

StyleBox tab_unselected

Property Value

StyleBox

Methods

add_tab(String, Texture2D)

Adds a new tab.

void add_tab(String title, Texture2D icon)

Parameters

title String
icon Texture2D

clear_tabs

Clears all tabs.

void clear_tabs

ensure_tab_visible(int)

Moves the scroll view to make the tab visible.

void ensure_tab_visible(int idx)

Parameters

idx int

get_offset_buttons_visible

Qualifiers: const

Returns true if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.

bool get_offset_buttons_visible

get_previous_tab

Qualifiers: const

Returns the previously active tab index.

int get_previous_tab

get_tab_button_icon(int)

Qualifiers: const

Returns the icon for the right button of the tab at index tab_idx or null if the right button has no icon.

Texture2D get_tab_button_icon(int tab_idx)

Parameters

tab_idx int

get_tab_icon(int)

Qualifiers: const

Returns the icon for the tab at index tab_idx or null if the tab has no icon.

Texture2D get_tab_icon(int tab_idx)

Parameters

tab_idx int

get_tab_icon_max_width(int)

Qualifiers: const

Returns the maximum allowed width of the icon for the tab at index tab_idx.

int get_tab_icon_max_width(int tab_idx)

Parameters

tab_idx int

get_tab_idx_at_point(Vector2)

Qualifiers: const

Returns the index of the tab at local coordinates point. Returns -1 if the point is outside the control boundaries or if there's no tab at the queried position.

int get_tab_idx_at_point(Vector2 point)

Parameters

point Vector2

get_tab_language(int)

Qualifiers: const

Returns tab title language code.

String get_tab_language(int tab_idx)

Parameters

tab_idx int

get_tab_metadata(int)

Qualifiers: const

Returns the metadata value set to the tab at index tab_idx using TabBar.set_tab_metadata. If no metadata was previously set, returns null by default.

Variant get_tab_metadata(int tab_idx)

Parameters

tab_idx int

get_tab_offset

Qualifiers: const

Returns the number of hidden tabs offsetted to the left.

int get_tab_offset

get_tab_rect(int)

Qualifiers: const

Returns tab Rect2 with local position and size.

Rect2 get_tab_rect(int tab_idx)

Parameters

tab_idx int

get_tab_text_direction(int)

Qualifiers: const

Returns tab title text base writing direction.

int get_tab_text_direction(int tab_idx)

Parameters

tab_idx int

get_tab_title(int)

Qualifiers: const

Returns the title of the tab at index tab_idx.

String get_tab_title(int tab_idx)

Parameters

tab_idx int

get_tab_tooltip(int)

Qualifiers: const

Returns the tooltip text of the tab at index tab_idx.

String get_tab_tooltip(int tab_idx)

Parameters

tab_idx int

is_tab_disabled(int)

Qualifiers: const

Returns true if the tab at index tab_idx is disabled.

bool is_tab_disabled(int tab_idx)

Parameters

tab_idx int

is_tab_hidden(int)

Qualifiers: const

Returns true if the tab at index tab_idx is hidden.

bool is_tab_hidden(int tab_idx)

Parameters

tab_idx int

move_tab(int, int)

Moves a tab from from to to.

void move_tab(int from, int to)

Parameters

from int
to int

remove_tab(int)

Removes the tab at index tab_idx.

void remove_tab(int tab_idx)

Parameters

tab_idx int

select_next_available

Selects the first available tab with greater index than the currently selected. Returns true if tab selection changed.

bool select_next_available

select_previous_available

Selects the first available tab with lower index than the currently selected. Returns true if tab selection changed.

bool select_previous_available

set_tab_button_icon(int, Texture2D)

Sets an icon for the button of the tab at index tab_idx (located to the right, before the close button), making it visible and clickable (See TabBar.tab_button_pressed). Giving it a null value will hide the button.

void set_tab_button_icon(int tab_idx, Texture2D icon)

Parameters

tab_idx int
icon Texture2D

set_tab_disabled(int, bool)

If disabled is true, disables the tab at index tab_idx, making it non-interactable.

void set_tab_disabled(int tab_idx, bool disabled)

Parameters

tab_idx int
disabled bool

set_tab_hidden(int, bool)

If hidden is true, hides the tab at index tab_idx, making it disappear from the tab area.

void set_tab_hidden(int tab_idx, bool hidden)

Parameters

tab_idx int
hidden bool

set_tab_icon(int, Texture2D)

Sets an icon for the tab at index tab_idx.

void set_tab_icon(int tab_idx, Texture2D icon)

Parameters

tab_idx int
icon Texture2D

set_tab_icon_max_width(int, int)

Sets the maximum allowed width of the icon for the tab at index tab_idx. This limit is applied on top of the default size of the icon and on top of icon_max_width. The height is adjusted according to the icon's ratio.

void set_tab_icon_max_width(int tab_idx, int width)

Parameters

tab_idx int
width int

set_tab_language(int, String)

Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

void set_tab_language(int tab_idx, String language)

Parameters

tab_idx int
language String

set_tab_metadata(int, Variant)

Sets the metadata value for the tab at index tab_idx, which can be retrieved later using TabBar.get_tab_metadata.

void set_tab_metadata(int tab_idx, Variant metadata)

Parameters

tab_idx int
metadata Variant

set_tab_text_direction(int, int)

Sets tab title base writing direction.

void set_tab_text_direction(int tab_idx, int direction)

Parameters

tab_idx int
direction int

set_tab_title(int, String)

Sets a title for the tab at index tab_idx.

void set_tab_title(int tab_idx, String title)

Parameters

tab_idx int
title String

set_tab_tooltip(int, String)

Sets a tooltip for tab at index tab_idx.

Note: By default, if the tooltip is empty and the tab text is truncated (not all characters fit into the tab), the title will be displayed as a tooltip. To hide the tooltip, assign " " as the tooltip text.

void set_tab_tooltip(int tab_idx, String tooltip)

Parameters

tab_idx int
tooltip String

Events

active_tab_rearranged(int)

Emitted when the active tab is rearranged via mouse drag. See drag_to_rearrange_enabled.

signal active_tab_rearranged(int idx_to)

Parameters

idx_to int

tab_button_pressed(int)

Emitted when a tab's right button is pressed. See TabBar.set_tab_button_icon.

signal tab_button_pressed(int tab)

Parameters

tab int

tab_changed(int)

Emitted when switching to another tab.

signal tab_changed(int tab)

Parameters

tab int

tab_clicked(int)

Emitted when a tab is clicked, even if it is the current tab.

signal tab_clicked(int tab)

Parameters

tab int

tab_close_pressed(int)

Emitted when a tab's close button is pressed.

Note: Tabs are not removed automatically once the close button is pressed, this behavior needs to be programmed manually. For example:

$TabBar.tab_close_pressed.connect($TabBar.remove_tab)

signal tab_close_pressed(int tab)

Parameters

tab int

tab_hovered(int)

Emitted when a tab is hovered by the mouse.

signal tab_hovered(int tab)

Parameters

tab int

tab_rmb_clicked(int)

Emitted when a tab is right-clicked. select_with_rmb must be enabled.

signal tab_rmb_clicked(int tab)

Parameters

tab int

tab_selected(int)

Emitted when a tab is selected via click, directional input, or script, even if it is the current tab.

signal tab_selected(int tab)

Parameters

tab int