setTabHighlighted() for Lightning Experience

Highlights the specified tab with a different background color and a badge. Tab highlights don’t persist after reloading a Lightning console app. This method works only in Lightning console apps.

NameTypeDescription
tabIdstringThe ID of the tab to be highlighted.
highlightedbooleanWhether the tab is highlighted. Makes a utility more prominent by giving it a different background color.
optionsobjectOptional. Additional options that modify the appearance of the highlighted tab. Available options are:
  • pulse: If true, causes two colors to alternate in a smooth animation.
  • state: Changes the tab color. Available types are success (green success color), warning (yellow warning color), and error (red error color).

This component checks if it’s in a Lightning console app, returns information about the focused tab and highlights it in green.

This example is the workspaceAPIHighlightTab 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.

This component has a button that, when pressed, sets the focused tab as highlighted.

Component code:

Controller code:

This method returns a promise that, upon success, returns 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.