Tabs

Tabs organize content into multiple sections, allowing users to switch between views within the same context.

UsageCodeAccessibility
Tab 1Tab 2Tab 3Tab 4Tab 5Panel 1Panel 2Panel 3Panel 4Panel 5
<sl-tab-group style="background: var(--sl-color-tab-default-background);">
  <sl-tab >Tab 1</sl-tab>
  <sl-tab selected>Tab 2</sl-tab>
  <sl-tab disabled>Tab 3</sl-tab>
  <sl-tab>Tab 4</sl-tab>
  <sl-tab>Tab 5</sl-tab>
  <sl-tab-panel>Panel 1</sl-tab-panel>
  <sl-tab-panel>Panel 2</sl-tab-panel>
  <sl-tab-panel>Panel 3</sl-tab-panel>
  <sl-tab-panel>Panel 4</sl-tab-panel>
  <sl-tab-panel>Panel 5</sl-tab-panel>
</sl-tab-group>

Tab group API

Component has a range of properties to define the experience in different use cases.

Properties

NameAttributeTypeDefaultDescription
activationactivation'auto' | 'manual' | undefined'manual'Determines when the contents of a tab is shown. Auto means the contents will be
shown when the tab is focused. Manual means the user has to activate the tab first
by clicking or using the keyboard.

For backwards compatibility, the default is 'manual'.
alignTabsalign-tabs'start' | 'center' | 'end' | 'stretch' | undefined'start'The alignment of tabs within the wrapper.
verticalverticalboolean | undefinedfalseRenders the tabs vertically instead of the default horizontal.

Events

NameEvent typeDescription
sl-tab-changeSlTabChangeEventEmits when the tab has been selected/changed.

Slots

NameDescription
defaultTab panels or other tab content here.
tabsThe tabs to display.

CSS Properties

NameDescription
--sl-tab-group-menu-min-inline-sizeThe minimum inline size of the menu.
--sl-tab-group-menu-max-inline-sizeThe maximum inline size of the menu.

CSS Parts

NameDescription
containerThe container for the tabs.
wrapperWraps the scroll container and menu button.
scrollerThe scroll container of the tabs.
tablistThe tablist element which also contains the active tab indicator
panelsThe container for the tab panels. Use this part to set the background color of all panels at once.

Tab panel API

Component has a range of properties to define the experience in different use cases.

Slots

NameDescription
defaultA place for the tab panel content.

Tab API

Component has a range of properties to define the experience in different use cases.

Properties

NameAttributeTypeDefaultDescription
disableddisabledboolean | undefinedWhether the tab item is disabled.
hrefhrefstring | undefinedWhen set, it will render the tab contents in a link tag. Use this when you
want to render the tab contents using a router and to make the tab
navigable by URL.
selectedselectedboolean | undefinedfalseIndicates if this tab is selected.

Slots

NameDescription
defaultA place for the tab group content.
iconIcon shown on the left side of the component.
badgeA place for badge component.
subtitleSubtitle of the tab, containing additional information.
Interactive example