Components / Library Version 4.9.0


This component is used to switch among related views within the same context. It is composed of three elements: wm-tab-list, wm-tab-item and wm-tab-panel.

The event wmTabSelected is emitted whenever the user changes the tab. It should be used to display the appropriate content. You can either use a single tab panel and conditionally change its content, or have a panel for each tab and switch between them.


* Required property

Properties of wm-tab-list

Changes the component theme. Set to dark for dark theme, unset for default (light) theme. Use sparingly! Dark tabs are an older design and are being phased out.
Changes the horizontal padding around all children wm-tab-items. Accepts valid CSS values e.g. 24px.
The tabId of the tab item to display as selected.

Properties of wm-tab-item and wm-tab-panel

tab-id *
Required for every tab item. If you are using discrete tab panels to wrap content, each tab panel should also have a tabId matching the tabId of the corresponding tab item. If you are conditionally rendering content in one tab panel, give the tab panel the tabId of tab item that will be selected on load.

Usage in HTML

Edit the code below to see changes reflected in the example above.

Note: The second example demonstrates how the component can be used to dynamically change the content when a tab is selected (using the wmTabSelected event).

Javascript Sample

Example code for functionality.

Usage in Elm

Code generated from HTML.

Emitted when a tab item is selected. The event detail stores a reference to the tab id of the selected tab item, which corresponds to the tab id of a panel.

Screen Readers

The component sets the recommended aria-controls attributes for the tab items and the aria-labelledby attribute for the tab panels. When one tab panel is used to conditionally render content, the component updates these attributes when a new tab item is selected.

Keyboard Support

Key Function
Enter Space Activates the tab item and triggers a change in the view.
  • From outside the component, moves focus to the selected tab item.
  • From a tab item, moves focus to the first focusable element in the tab panel (if there is an interactive element in the panel).
Shift + Tab
  • From a tab item, moves focus out of the tab list to the previous focusable element on the page.
  • From the first focusable element in the tab panel, moves focus to the selected tab item if pressed.
Arrow Left
  • If a tab item is in focus, moves focus to the previous tab item.
  • If focus is on the first tab item, focus moves to the last tab item.
Arrow Right
  • If a tab item is in focus, moves focus to the next tab item.
  • If focus is on the last tab item, focus moves to the first tab item.
Arrow Down Focuses the tab panel. This is to ensure the content in the tab panel is more easily accessible to screen reader users. While in the tab widget, the screen reader is in focus mode, meaning the user is not able to browse using the arrow down key. If the tab panel contains no interactive elements, tabbing would move focus to the first interactive element outside the tab panel, meaning that users would lose their place and access to the tab content. If the component captures the arrow-down event and shifts focus to the tab panel outside the widget, it essentially gives control back to the screen reader, and users can more easily browse the content of the tabpanel.

Most of the time you will want to set the container's width to 100%. If the container's width is unset, it will change according to its content. Since the component in turn checks its parent to determine the available space and adjust its display, this is likely to produce undesirable behavior.