Tree Navigation
Collapsible tree navigation using native details/summary elements. Works without JavaScript.
Overview
This pattern creates a hierarchical navigation menu with collapsible sections. It uses native HTML5 <details> and <summary> elements for the expand/collapse functionality, requiring no JavaScript.
Key features:
- Progressive enhancement - works without JavaScript
- Native keyboard accessibility
- Supports unlimited nesting depth
- Active state via
aria-current="page" - Compact density option via
data-layout-density
Live Example
A tree navigation with multiple nesting levels and an active page indicator.
Source Code
Copy this snippet and customize the links, labels, and nesting structure for your navigation.
Variants
Default Density
Without data-layout-density="compact", the navigation has more generous spacing.
Usage Notes
- Accessibility: Always include
aria-labelon the<nav>element to identify its purpose - Active state: Use
aria-current="page"on the link representing the current page - Open sections: Add the
openattribute to<details>elements that should be expanded by default - Styling: The
.treeclass applies Vanilla Breeze navigation styles automatically
Related
Nav Element
Native navigation element documentation
Details Element
Native disclosure widget documentation
Article Layout
Page layout with sidebar navigation