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

details

The native HTML disclosure widget for expandable content. Creates an interactive widget that users can open and close without JavaScript.

Description

The <details> element creates a disclosure widget where the contents are visible only when toggled "open." It must contain a <summary> element as its first child, which provides the clickable label.

This is one of the few truly interactive HTML elements that works entirely without JavaScript. In Vanilla Breeze it serves as the foundation for several higher-level components: <accordion-wc>, <tab-set>, and tree navigation all build on native details/summary.

When to Use

  • FAQ sections: Questions with expandable answers
  • Collapsible content: Hide supplementary information by default
  • Accordion patterns: Group related collapsible items
  • Progressive disclosure: Reveal complex forms or options step by step
  • Tree navigation: Collapsible menu sections (via nav.tree)
  • Code examples: Optionally viewable source code

When Not to Use

  • For modals or overlays — use <dialog>
  • For dropdown menus with positioning — use <drop-down> or <context-menu>
  • When content must always be visible — avoid hiding critical-path information
  • When you need keyboard arrow navigation between panels — use <accordion-wc>

Basic Usage

A single details element with a summary label. Use the open attribute to start expanded.

Stacked Details (Accordion)

Adjacent <details> elements automatically stack with connected borders — the border-radius is removed between siblings and the top border overlaps to prevent doubling.

Joining only happens in normal flow. When the parent is a gap-based layout primitive (<layout-stack>, <layout-grid>, any [data-layout] or [data-layout-gap] element) the items are visually separated, so each keeps its own border and radius. Use data-layout-gap="none" to join them inside a layout primitive.

For enhanced keyboard navigation (Arrow Up/Down, Home/End) and ARIA attributes, wrap in <accordion-wc>.

Exclusive Accordion (name attribute)

The name attribute groups details elements so only one can be open at a time. This is a native browser feature requiring no JavaScript.

Tip: The <accordion-wc> component also supports exclusive mode via single, adding keyboard navigation and View Transitions on top.

Rich Content

Details can contain any flow content: lists, definition lists, tables, images, and VB layout primitives.

As a Foundation for Web Components

In Vanilla Breeze, <details> / <summary> is the progressive enhancement base for two major web components. Both use the same HTML structure but add keyboard navigation, ARIA roles, and optional View Transitions.

accordion-wc

Wraps details elements with ARIA accordion keyboard navigation (Arrow Up/Down, Home/End) and optional single for exclusive mode.

tab-set

Transforms details elements into a tabbed interface. Summaries become the tab row and content panels display below. Uses CSS display: contents on details for grid participation.

Tree Navigation

The nav.tree variant uses nested details/summary for collapsible hierarchical menus. The nav context resets details styling and uses a +/− indicator instead of the chevron.

See nav for more tree navigation variants.

CSS Reference

Base Styling

Open/Close Animation

Vanilla Breeze uses the ::details-content pseudo-element for smooth height animation. Animating block-size to auto also needs interpolate-size: allow-keywords (set on :root by VB's motion tokens), which is currently Chromium-only. This is progressive — other browsers simply show/hide instantly.

Context Overrides

Several contexts reset or extend the base details styling:

Context What Changes
nav Removes border, border-radius, and content padding. Details used for grouping, not disclosure.
nav.tree Replaces chevron with +/− indicator. Adds indentation for nested levels.
accordion-wc Removes the details border and radius (the accordion draws its own), restyles summary and indicator. Adds ARIA and keyboard navigation.
tab-set Sets display: contents. Summary becomes tab button in grid row 1.
@media print Reveals closed panels via ::details-content. Hides chevron markers.

Print Behavior

In print stylesheets, all <details> content is forced visible regardless of the open attribute, so collapsed content is not lost when printing. The chevron indicator is hidden. Closed content lives inside the ::details-content pseudo-element (hidden with content-visibility), so the print rule targets that box rather than the children.

Attributes

Attribute Type Description
open boolean When present, the content is visible. Toggled by user interaction or JavaScript.
name string Groups details elements. Only one with the same name can be open at a time.

JavaScript API

The <details> element can be controlled programmatically via the open property and the toggle event.

Events

Event Description
toggle Fired when the open state changes. The open property reflects the new state.

Accessibility

Built-in Accessibility

  • The <summary> element receives automatic button-like keyboard behavior
  • Screen readers announce the expanded/collapsed state
  • Enter and Space keys toggle the state when summary is focused

Best Practices

  • Always include a <summary> as the first child
  • Keep summary text concise and descriptive
  • Avoid nesting interactive elements inside <summary>
  • Ensure hidden content is not critical path information
  • For multiple related panels, consider <accordion-wc> for keyboard arrow navigation between summaries

Keyboard Support

Key Action
Enter Toggle open/closed when summary is focused
Space Toggle open/closed when summary is focused

Related

  • <summary> — Required clickable child that provides the toggle label
  • <accordion-wc> — Enhanced accordion with Arrow/Home/End keyboard navigation and ARIA
  • <tab-set> — Tab interface built on details/summary with grid layout
  • <nav> — Tree navigation variant uses details for collapsible sections
  • <dialog> — For modal overlays rather than inline disclosure
  • open — The expanded state, and exclusive accordions with name
  • hidden — hidden="until-found" for collapsed content that find-in-page can reveal

Patterns Using This Element

The <details> element is used across many patterns:

FAQ

Accordion-style questions and answers

Sidebar

Collapsible navigation sections

Wizard

Multi-step form disclosure

Checkout

Expandable checkout sections

App Shells

Collapsible application panels

Timeline

Expandable event details

Browser Support

The <details> element is supported in all modern browsers. The name attribute for exclusive accordions is supported in Chrome 120+, Safari 17.2+, and Firefox 130+. The ::details-content pseudo-element is supported in Chrome 131+, Safari 18.4+ and Firefox 143+; the open/close height animation additionally needs interpolate-size, which only Chromium supports, so Safari and Firefox open and close instantly. Printing closed panels relies on ::details-content; older browsers print only open panels.

↑