Closes a workspace tab or subtab. This method works only in Lightning console apps.
Arguments
The method provides the same argument for both Aura Components and Lightning Web Components (LWC).
Name
Type
Description
tabId
string
ID of the workspace tab or subtab to close.
LWC Sample Code
This component checks if it’s in a Lightning console app using the isConsoleNavigation wire adapter. When the getFocusedTabInfo() resolves successfully, it returns the tabInfo object. The const { tabId } syntax destructures the tabInfo object and binds the tabInfo.tabId value on the tabId variable. closeTab() uses this tabId value to close the tab.