---
schema_version: "1"
id: 793aaa75897a34f4395e7bb5c9e602002bb10cedfe2487b48ab3433bd868747a
title: Tab Focused
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/aura/components/lightning/tabFocused/aura-tab-focused.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/aura-tab-focused.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6e4501e05d08e4bc76c2ddc022d4345290dcc40ec387857f111d18c63c109eef
products:
  - Lightning Component Reference
---
# Tab Focused

**`lightning:tabFocused`**

Fires when a Console workspace or subtab is focused.

**For Use In**

Lightning Experience

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

`lightning:tabFocused` is an application event that indicates a successful tab focus change. The event fires when any tab is successfully focused. This event is supported only in Lightning console apps.

`lightning:tabFocused` fires whenever a user selects a workspace tab or subtab, so console navigation users frequently trigger this application event in typical use. This event also fires when going from a tab to a navigation item, or going from a navigation item to a tab.

Aura application events notify all listeners registered in the default phase, including listeners in background tabs. Multiple listeners responding at the same time can impact performance.

To minimize performance impact, use a [background utility item](/docs/platform/lightning-component-reference/guide/aura-background-utility-item.html) as the only listener, or use a custom component event instead.

Handle the event using `aura:handler`.

```html
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
  <lightning:workspaceAPI aura:id="workspace" />
  <aura:handler event="lightning:tabFocused" action="{! c.onTabFocused }" />
</aura:component>
```

In your client-side controller, retrieve the ID of the tab that's currently focused.

```javascript
({
  onTabFocused: function (component, event, helper) {
    var focusedTabId = event.getParam("currentTabId");
    var workspaceAPI = component.find("workspace");
    workspaceAPI.getTabInfo({
      tabId: focusedTabId,
      callback: function (error, response) {
        console.log(response);
      },
    });
  },
});
```

For more information, see the [Salesforce Console Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/).


:::::

:::::tab
## Attributes

| Name            | Description                    | Type   | Default | Required                                     |
| --------------- | ------------------------------ | ------ | ------- | -------------------------------------------- |
| `currentTabId`  | The currently focused tab ID.  | string |         | ![Yes](https://developer.salesforce.com/media/check.png) |
| `previousTabId` | The previously focused tab ID. | string |         | ![Yes](https://developer.salesforce.com/media/check.png) |

:::::

::::::
