Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

tab-set

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.

Attributes

AttributeValuesDefaultDescription
aria-labelstring—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"horizontalVertical 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

ElementRequiredDescription
<details>yesOne 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>yesTab label inside each <details>
<section>yesExactly 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

Child Details Attributes

Attribute Type Description
name string 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 name attribute (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.

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.

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.

JavaScript API

Control tabs by setting open on the underlying <details> elements, or replace the whole set with the tabs property.

View Transitions

Add transition to enable animated tab switches using the View Transitions API. Three animation types are available:

ValueEffect
fade (default)Crossfade between panels
slideDirectional slide — forward when moving right, backward when moving left
scaleScale down old panel, scale up new panel

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.

Dark mode

Tabs use theme tokens, so data-mode="dark" on the page (or any ancestor) is all a dark set needs.

Print

With the print utilities loaded, a printed tab-set shows every panel in order, each under its tab label as a heading.

↑