Tab Group

<wa-tab-group> Stable Since 2.0

Tab groups organize related content into a single container that displays one panel at a time, with tabs for switching between them.

Tab groups make use of tabs and tab panels. Each panel should have a name that's unique within the tab group, and tabs should have a panel attribute that points to the respective panel's 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.

Examples

Link to This Section

Setting the Active Tab

Link to This Section

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.

Tabs on Bottom

Link to This Section

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 on Start

Link to This Section

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 on End

Link to This Section

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.

Closable Tabs

Link to This Section

You can make a tab closable by adding a close button next to the tab and inside the nav slot. You can position the button to your liking with CSS and handle close/restore behaviors by removing/appending the tab as desired. Note the use of tabindex="-1", which prevents the close button from interfering with the tab order. The close button is still recognizable to the virtual cursor in screen readers.

General Closable Advanced This is the general tab panel. This is the closable tab panel. This is the advanced tab panel.
Restore tab

Scrolling Tabs

Link to This Section

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

Manual Activation

Link to This Section

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.

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/tab-group/tab-group.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/tab-group/tab-group.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/tab-group/tab-group.js';

To import this component for React 18 or below, use the following code:

import WaTabGroup from '@awesome.me/webawesome/dist/react/tab-group/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Events

Link to This Section

Learn more about events.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results