Newer Version Available
setTabLabel() for Lightning Experience
Sets the label of the specified tab. This method works only in
Lightning console apps.
Arguments
| Name | Type | Description |
|---|---|---|
| tabId | string | The ID of the tab for which to set the label. |
| label | string | The label of the workspace tab or subtab. |
LWC Sample Code
This component has a function that sets a label on a specified tab. It uses the tabId property from getFocusedTabInfo().
This example is the workspaceAPISetTabLabel component from the lwc-recipes repo.
To make your component available for use in a Lightning console app, specify the lightning__AppPage target in the component’s configuration file.
Aura Components Sample Code
This component has a button that, when pressed, sets the label of the focused tab to “Focused Tab”.
Component code:
Controller code:
Response
This method returns a promise that, upon success, resolves
to a tabInfo object representing the modified tab.
A
tabInfo object is a JSON array of
information about a workspace tab, with nested arrays of information on each subtab.
This is the structure of a tabInfo
object.