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

Tab

<sl-tab> | SlTab

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
import SlTab from '@teamshares/shoelace/dist/react/tab';

const App = () => (
  <>
    <SlTab>Tab</SlTab>
    <SlTab active>Active</SlTab>
    <SlTab closable>Closable</SlTab>
    <SlTab disabled>Disabled</SlTab>
  </>
);

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 React Event Details
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.

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>