Tab Group

Tab groups organize content into a container that shows one section at a time.

To make a tab active, set the active attribute to the name of the appropriate panel.

General Custom Advanced This is the general tab panel. This is the custom tab panel. This is the advanced tab panel.

Tab groups make use of tabs and tab panels. Each tab must be slotted into the nav slot and its panel must refer to a tab panel of the same name.

General Custom Advanced Disabled This is the general tab panel. This is the custom tab panel. This is the advanced tab panel. This is a disabled tab panel.

Tabs can be shown on the bottom by setting placement to bottom.

General Custom Advanced Disabled This is the general tab panel. This is the custom tab panel. This is the advanced tab panel. This is a disabled tab panel.

Tabs can be shown on the starting side by setting placement to start.

General Custom Advanced Disabled This is the general tab panel. This is the custom tab panel. This is the advanced tab panel. This is a disabled tab panel.

Tabs can be shown on the ending side by setting placement to end.

General Custom Advanced Disabled This is the general tab panel. This is the custom tab panel. This is the advanced tab panel. This is a disabled tab panel.

Add the closable attribute to a tab to show a close button. This example shows how you can dynamically remove tabs from the DOM when the close button is activated.

General Closable 1 Closable 2 Closable 3 This is the general tab panel. This is the first closable tab panel. This is the second closable tab panel. This is the third closable tab panel.

When there are more tabs than horizontal space allows, the nav will be scrollable.

Tab 1 Tab 2 Tab 3 Tab 4 Tab 5 Tab 6 Tab 7 Tab 8 Tab 9 Tab 10 Tab 11 Tab 12 Tab 13 Tab 14 Tab 15 Tab 16 Tab 17 Tab 18 Tab 19 Tab 20 Tab panel 1 Tab panel 2 Tab panel 3 Tab panel 4 Tab panel 5 Tab panel 6 Tab panel 7 Tab panel 8 Tab panel 9 Tab panel 10 Tab panel 11 Tab panel 12 Tab panel 13 Tab panel 14 Tab panel 15 Tab panel 16 Tab panel 17 Tab panel 18 Tab panel 19 Tab panel 20

When focused, keyboard users can press Left or Right to select the desired tab. By default, the corresponding tab panel will be shown immediately (automatic activation). You can change this behavior by setting activation=“manual” which will require the user to press Space or Enter before showing the tab panel (manual activation).

General Custom Advanced Disabled This is the general tab panel. This is the custom tab panel. This is the advanced tab panel. This is a disabled tab panel.

When using Tabs with routers like React Router, do not use Tab Panel. To handle routing, listen for a click event on Tab Group and provide a handler to implement your route.

General Custom Advanced
import '@ods/components/web.tab-group';

Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.

Slots

NameDescription
(default)Used for grouping tab panels in the tab group. Must be `<ods-tab-panel>` elements.
navUsed for grouping tabs in the tab group. Must be `<ods-tab>` elements.

Properties

Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.

Property/AttributeReflectsTypeDefault
active
string''
placement
'top' | 'bottom' | 'start' | 'end''top'
activation
'auto' | 'manual''auto'
noScrollControls
no-scroll-controls
booleanfalse
hidetrack
booleanfalse

Events

React EventDescriptionEvent Detail
ods-tab-showEmitted when a tab is shown.--
ods-tab-hideEmitted when a tab is hidden.--

Methods

NameDescriptionArguments
show()Shows the specified tab panel.--

Parts

NameDescription
baseThe component's base wrapper.
navThe tab group's navigation container where tabs are slotted in.
tabsThe container that wraps the tabs.
active-tab-indicatorThe line that highlights the currently selected tab.
bodyThe tab group's body where tab panels are slotted in.
scroll-buttonThe previous/next scroll buttons that show when tabs are scrollable, an `<ods-icon-button>`.
scroll-button--startThe starting scroll button.
scroll-button--endThe ending scroll button.
scroll-button__baseThe scroll button's exported `base` part.

Dependencies

This component automatically imports the following dependencies.

  • ods-icon
  • ods-icon-button

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use Tabs to contain multiple panels of content within a single window or container
  • Use Tabs to organize similar content types related to the user needs

Dont

  • Use tabs as a primary navigation pattern - use side nav
  • Use any other components within tab groups other than tabs
  • Put related tasks on different tabs
  • Avoid nesting additional Tabs within Tab Panels

Search