Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-tree-nav>

@methane-ui/ui~7.9 KB brotli (cold + Lit)~2.0 KB marginal

Hierarchical collapsible navigation tree with WAI-ARIA tree/treeitem keyboard navigation, LTR/RTL branch expand/collapse, roving focus, and safe URL validation.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-tree-nav> (@methane-ui/ui)
Documentation
Ready · interact with <mth-tree-nav>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/tree-nav"></script>
<mth-tree-nav></mth-tree-nav>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
labellabelstring""Accessible label for the <nav> landmark and tree.
activeValueactive-valuestring""Value of the currently active node marked aria-current="page".
activeHrefactive-hrefstring""Href of the currently active node marked aria-current="page".
expandedValues—ReadonlyArray<string>[]Values of currently expanded branch nodes.
items—ReadonlyArray<unknown>[]Nested tree structure of navigation nodes.

Events

EventDetail TypeDescription
mth-select{ value: string; label: string; href?: string }Fired when a tree navigation node is activated.
mth-toggle{ value: string; expanded: boolean }Fired when a branch node expands or collapses.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowDownbothtreeitem focusedmoves focus to next visible enabled treeitem
ArrowUpbothtreeitem focusedmoves focus to previous visible enabled treeitem
ArrowRightltrbranch treeitem focusedexpands collapsed branch or enters first child
ArrowLeftltrbranch or child treeitem focusedcollapses expanded branch or focuses parent
Homebothtreeitem focusedmoves focus to first visible enabled treeitem
Endbothtreeitem focusedmoves focus to last visible enabled treeitem

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 6 APG keyboard transitions across LTR/RTL.mth-tree-nav.spec.test.ts
i18nRoutes 2 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test