0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Tabbed content panels with keyboard navigation and ARIA semantics.
Overview
The <tab-set> component transforms a group of <details> elements into a tab interface. Without JavaScript, it works as an accordion. With JavaScript, it adds keyboard navigation and ARIA linkage attributes while preserving native <details>/<summary> semantics.
Basic tabs usage
1234567891011121314
<tab-setaria-label="Feature tabs"><detailsname="feature-tabs"open><summary>Overview</summary><section>Content for Overview tab</section></details><detailsname="feature-tabs"><summary>Features</summary><section>Content for Features tab</section></details><detailsname="feature-tabs"><summary>Usage</summary><section>Content for Usage tab</section></details></tab-set>
Names the set of tabs. When the host has aria-label or aria-labelledby (and no role of its own) it gets role="group" on upgrade, so the name is exposed; an unlabelled tab-set stays role-less. Read at upgrade.
data-orientation
"horizontal", "vertical"
horizontal
Vertical puts the tabs in a column at the inline start with the panel beside them, and moves between tabs with ArrowUp/ArrowDown in place of ArrowLeft/ArrowRight. Horizontal tabs wrap onto further rows when they don't fit.
transition
"fade", "slide", "scale"
—
View Transition animation between tab panels
Required Structure
Element
Required
Description
<details>
yes
One per tab — native disclosure element provides open/close state. Give every tab the same name for no-JS exclusivity; on upgrade a missing, mixed or page-shared name is replaced with a per-instance one
<summary>
yes
Tab label inside each <details>
<section>
yes
Exactly one panel element per <details>, after the summary. Use <section>: it is named by its tab (aria-labelledby) and exposed as a region; a <div> panel's name is ignored
Shared name for exclusive behavior. All tabs should have the same name. On upgrade, a missing, mixed, or page-shared name (another <details> outside this set uses it) is replaced with a per-instance tab-set-N, so two tab-sets never close each other's tabs.
open
boolean
Initially selected tab. If none specified, first tab is selected.
Panels
Each <details> holds one <summary> and exactly one panel element after it. Wrap the panel content in a <section>: the component names it from its tab with aria-labelledby, which makes it a region. A <div> panel can't carry that name, and two or more loose children would each be laid out as a separate panel.
Progressive Enhancement
The component is built on the native <details> element, which provides built-in expand/collapse functionality. The shared nameattribute (supported in modern browsers) ensures only one panel is open at a time.
Without JavaScript
When JavaScript is disabled or fails to load, the tabs fall back to an exclusive accordion: the panels stack under their summaries, and the shared name still keeps only one open at a time. When the element is defined, the summaries move into the tab row.
With JavaScript
Native <details>/<summary> semantics are preserved (no role overrides)
aria-controls and aria-labelledby link each tab to its panel
aria-expanded state is managed on each summary
Every tab stays in the tab order
Keyboard navigation (arrow keys, Home, End) is enabled
A labelled host gets role="group"
Keyboard Navigation
When focused on a tab, the following keyboard shortcuts are available:
Key
Action
ArrowRight
Move to and activate the next tab (the previous one in right-to-left text). Horizontal tabs only
ArrowLeft
Move to and activate the previous tab (the next one in right-to-left text). Horizontal tabs only
ArrowDown / ArrowUp
Next / previous tab, with data-orientation="vertical" only
Home
Move to and activate the first tab
End
Move to and activate the last tab
Try using arrow keys to navigate between tabs:
Rich Tab Content
Tabs can contain any HTML content, including forms, images, and other components.
Vertical Tabs
Add data-orientation="vertical" to put the tabs in a column at the inline start with the panel beside them. ArrowDown and ArrowUp move between tabs; the left and right arrows do nothing in a vertical tab-set.
Vertical tabs
12345678910
<tab-setaria-label="Account settings"data-orientation="vertical"><detailsname="settings"open><summary>General</summary><section><p>General settings and preferences.</p></section></details><detailsname="settings"><summary>Security</summary><section><p>Security and privacy options.</p></section></details></tab-set>
Many Tabs and Right-to-Left
When the tabs don't fit on one line they wrap onto another row, so a narrow screen never scrolls sideways. In right-to-left text the row runs from the right, and the arrow keys follow what you see: ArrowLeft moves to the next tab.
Events
The component dispatches a custom event when a tab is changed.
Event
Detail
Description
tab-set:change
{ index, previousIndex, tab, panel }
Fired once each time a tab is activated (click, arrow key, or setting details.open), from the newly opened tab. index is the new 0-based tab index, previousIndex the tab it replaced, tab its <details> and panel its panel. Not fired during setup or when the open tab is selected again.
tab-set:tabs-changed
{ tabs, source: 'property' }
Fired after the tabs property rebuilds the set.
Event handling
12345678910
<script>const tabs = document.querySelector('tab-set');tabs.addEventListener('tab-set:change', (event) => {const { index, previousIndex, tab } = event.detail;// The event bubbles: with nested tab-sets, check which set it came from.if (tab.parentElement !== tabs) return;console.log(`Tab changed from ${previousIndex} to ${index}`);});</script>
Accessibility
Native Semantics
The component preserves native <details>/<summary> semantics. It does not override roles with role="tablist", role="tab", or role="tabpanel". Instead, it layers ARIA linkage attributes on top of the native elements:
aria-controls on each <summary> points to its panel
aria-labelledby on each panel points back to its summary
aria-expanded reflects which tab is currently open
Every tab stays in the tab order. The tabs are announced as buttons, so Tab reaches each one and Enter or Space opens it. The arrow keys are a faster way across, not the only one.
A host with aria-label or aria-labelledby (and no role of its own) gets role="group", so the name is announced. An unlabelled tab-set gets no role: aria-label on a role-less element is ignored.
In forced-colors mode the selected tab's border uses the system Highlight colour.
Screen Reader Behavior
Screen readers announce each tab as a button that is expanded or collapsed, and name the open panel after its tab. Because the tabs are buttons and not role="tab", a screen reader gives no hint that arrow keys work, which is why Tab also reaches every one.
Accessibility
1234
<!-- Label the set: the host becomes a named group --><tab-setaria-label="Product information"> ...</tab-set>
JavaScript API
Control tabs by setting open on the underlying <details> elements, or replace the whole set with the tabs property.
JavaScript API
1234567891011121314151617181920212223
const tabs = document.querySelector('tab-set');// Get all tab panelsconst panels = tabs.querySelectorAll('details');// Programmatically open a tabpanels[1].open = true; // Opens the second tab// Check which tab is openconst openIndex = [...panels].findIndex(p => p.open);console.log('Open tab index:', openIndex);// Listen for changestabs.addEventListener('tab-set:change', (e) => {console.log('New tab:', e.detail.index);});// Read the tabs as data, or assign an array to rebuild the setconsole.log(tabs.tabs); // [{ id, label, content, active }, ...]tabs.tabs = [ { label: 'Overview', content: '<p>Overview</p>' }, { label: 'Pricing', content: '<p>Pricing</p>', active: true },];
View Transitions
Add transition to enable animated tab switches using the View Transitions API. Three animation types are available:
Value
Effect
fade (default)
Crossfade between panels
slide
Directional slide — forward when moving right, backward when moving left
scale
Scale down old panel, scale up new panel
Tabs with slide transition
1234567891011121314
<tab-settransition="slide"aria-label="Feature tour"><detailsname="tour"open><summary>Design</summary><section><p>Slides forward to the next tab, backward to previous.</p></section></details><detailsname="tour"><summary>Build</summary><section><p>Direction is computed automatically from tab index.</p></section></details><detailsname="tour"><summary>Ship</summary><section><p>Works with both mouse clicks and keyboard navigation.</p></section></details></tab-set>
Styling
Restyle the tabs and panels, but leave the host's display alone: the tab row and panel placement depend on it. Style the selected tab with details[open] > summary, the same selector the component uses.