Skip to main content
Since Shoelace 2.0 Code stable Pattern stable Figma ready

Tab

sl-tab

Tabs are used inside tab groups to represent and activate tab panels.

Examples

Basic Tab

Tab Active Closable Disabled
<sl-tab>Tab</sl-tab>
<sl-tab active>Active</sl-tab>
<sl-tab closable>Closable</sl-tab>
<sl-tab disabled>Disabled</sl-tab>
sl-tab Tab
sl-tab active=true Active
sl-tab closable=true Closable
sl-tab disabled=true Disabled

Component Props

Property Default Details
panel ''

string

The name of the tab panel this tab is associated with. The panel must be located in the same tab group.

active false

boolean

Draws the tab in an active state.

closable false

boolean

Makes the tab closable and shows a close button.

disabled false

boolean

Disables the tab and prevents selection.

updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Slots

Name Details
(default) The tab’s label.

Learn more about using slots.

Events

Name Name Name React Event Details
sl-close sl-close sl-close onSlClose

Emitted when the tab is closable and the close button is activated.

Learn more about events.

Methods

Name Details
focus()

options: FocusOptions

Sets focus to the tab.

blur()

Removes focus from the tab.

Learn more about methods.

Custom Properties

Name Details
--group-track-width

Used to calculate the tab’s padding and border width. Must match the tab group’s track width (default is 1px).

Learn more about customizing CSS custom properties.

CSS Parts

Name Description
base The component’s base wrapper.
close-button The close button, an <sl-icon-button>.
close-button__base The close button’s exported base part.

Learn more about customizing CSS parts.

Dependencies

This component automatically imports the following dependencies.

  • <sl-icon>
  • <sl-icon-button>