<divdata-paneldata-for="products"style="padding:.75rem">Product links live here.</div>
</hui-navigation-menu>
The Go template that renders it:
<hui-navigation-menulabel="Main">
{{ range .Items }}
<aclass="hui-nav-link"href="{{ .Href }}"{{ if .Current }} aria-current="page"{{ end }}{{ if .Value }} data-value="{{ .Value }}"{{ end }}>{{ .Label }}</a>
{{ end }}
<divdata-paneldata-for="products">…</div>
</hui-navigation-menu>
On a phone
When its links do not fit on one row, the bar folds behind a single button (its text is menu-label) and the links stack in a dropdown under it; it unfolds once there is room for the row. An item with a panel opens it inline, under the item. At any width, a tap or Enter on an item with a panel opens the panel rather than following the link - with JavaScript off, the link still works.
Five links fold behind one button375 px wideSource
The <nav> wrapping the links; the dropdown when they are folded.
toggle
The button the links fold behind when they do not fit. Hidden otherwise.
viewport
The positioned region the panel appears in.
States
This element has no states beyond its default.
Server-side mechanics
The server owns the items, their hrefs, which is current (aria-current="page"), and the panel contents; it may render a panel open with open. The element is not form-associated and submits nothing. The open panel is viewer-owned and announced with hui-open/hui-close. A swap that removes the element while a panel is open closes it with the element, leaving nothing behind.
Accessibility
The list is a <nav> landmark with a name from label.
Every item is a real link, so it can be opened in a new tab and works with JavaScript disabled.
A panel-owning link carries aria-expanded; the current one carries the server’s aria-current="page".
Keyboard
Keyboard
Keys
Action
Arrow Left/Right (or Up/Down)
Moves focus between the top-level links.
Enter
Follows the link; on an item with a panel, opens the panel and moves focus to its first link.
Escape
Closes the open panel and returns focus to its link; then closes the folded menu and returns focus to its button.
Gotchas
Panels are light-DOM [data-panel][data-for] children, not a slot; the element shows, hides and positions them. They must sit inside the element.
Navigation is links, not buttons that navigate: the dropdown is an enhancement over links that already work.
A click or tap on an item that owns a panel opens the panel and does not navigate, as a Radix trigger is a button. Give the panel a link to the item’s own page if it has one. With JavaScript off the item is a plain link again.