Tab

lightning:tab

A single tab that is nested in a lightning:tabset component.

For Aura components only. For LWC development, use lightning-tab.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline

A lightning:tab component keeps related content in a single container. The tab content displays when a user clicks the tab. Use lightning:tab as a child of the lightning:tabset component.

This component implements styling from tabs in the Lightning Design System.

Use the label attribute to specify the tab’s text label.

To include an icon at the beginning of the label, use the iconName attribute. Provide alternative text for the icon using the iconAssistiveText attribute.

To include an icon at the end of the label, use the endIconName attribute. Provide alternative text for that icon using the endIconAlternativeText attribute.

Set showErrorIndicator to true to display an error indicator in the tab after the label. If an end icon is present, the error indicator is displayed after the icon.

Usage Considerations 

Tab content is lazy loaded. You can only query the content for the active and previously active tabs. See lightning:tabset for more information.

You can nest lightning:tab within aura:if or aura:iteration. Otherwise, you must nest lightning:tab directly within lightning:tabset.

For example, you want to display a tab conditionally.

1<aura:component>
2  <aura:attribute name="displayMe" type="String" required="true" />
3  <lightning:tabset>
4    <aura:if isTrue="{!v.displayMe}">
5      <lightning:tab label="My Tab">
6        <!-- Your tab content -->
7      </lightning:tab>
8    </aura:if>
9  </lightning:tabset>
10</aura:component>

Attributes 

NameDescriptionTypeDefaultRequired
accesskeySpecifies a shortcut key to activate or focus an element.String
bodyThe body of the tab.Aura.ComponentDefRef[]
endIconAlternativeTextAlternative text for the icon specified by endIconName.String
endIconNameThe Lightning Design System name of an icon to display at the end of the tab label. Specify the name in the format 'utility:check' where 'utility' is the category, and 'check' is the icon to be displayed.String
iconAssistiveTextAlternative text for the icon specified by iconName.String
iconNameThe Lightning Design System name of an icon to display at the start of the tab label. Specify the name in the format 'utility:down' where 'utility' is the category, and 'down' is the icon to be displayed. Only utility icons can be used in this component.String
idThe optional ID is used during tabset's onselect event to determine which tab was clicked.String
labelThe text that appears on the tab. The attribute accepts string values, but for compatibility with previous releases also accepts a component type. Only the text portion of the label value displays and any CSS classes that are applied are ignored.Aura.Component[]
onactiveThe action triggered when this tab becomes active.Aura.Action
onblurThe action triggered when the element releases focus.Aura.Action
onfocusThe action triggered when the element receives focus.Aura.Action
showErrorIndicatorSpecifies whether there's an error in the tab content. An error icon is displayed to the right of the tab label.Boolean
tabindexSpecifies the tab order of an element when the Tab key is used for navigating. The tabindex value can be set to 0 or -1. The default is 0, which means that the component is focusable and participates in sequential keyboard navigation. -1 means that the component is focusable but does not participate in keyboard navigation.Integer

Methods 

NameDescriptionArgument NameArgument TypeArgument Description
focusSets focus on the element.