Tabs
Tab interface examples using tabs-wc with native details/summary. Progressive enhancement with ARIA roles and keyboard navigation.
Overview
The tabs component uses the <tabs-wc> web component built on native HTML <details> and <summary> elements with the name attribute for exclusive behavior. Progressive enhancement: tabs work without JavaScript.
Key features:
- Progressive enhancement with native details/summary
- Horizontal and vertical orientations
- Support for icons and badges in tab labels
- ARIA tab roles for accessibility
- Keyboard navigation with arrow keys
Basic Tabs
A simple horizontal tab interface. The name attribute groups the details elements for exclusive behavior.
Tabs with Icons
Add icons alongside tab labels for visual context. Use <icon-wc> inside the summary element.
Vertical Tabs
Add data-orientation="vertical" for a sidebar-style tab layout.
Configuration
The <tabs-wc> element accepts these attributes:
| Attribute | Values | Description |
|---|---|---|
aria-label |
String | Accessible label for the tab list. |
data-orientation |
horizontal vertical |
Tab layout direction. Default is horizontal. |
Details Element
Each tab panel uses a <details> element:
| Attribute | Values | Description |
|---|---|---|
name |
String | Groups details elements for exclusive behavior (required). |
open |
Boolean (presence) | Sets the initially selected tab. |
Usage Notes
- Name attribute: All details elements in a tab group must share the same
namevalue - Initial selection: Add
opento one details element to set the default tab - Accessibility: Always provide an
aria-labelon the tabs-wc element - Badges: Add
<span class="badge">inside summary for notification counts - Keyboard: Use arrow keys to navigate between tabs when focused
Related
Tabs WC
Web component documentation
Accordion
Accordion component