Navigation Menu
A horizontal site-header bar with hover or click flyout panels of link cards. It is a compound family composed over the shared Dropdown Panel base, so hover intent, the hover bridge, one-open-at-a-time arbitration, outside-press dismissal and the whole keyboard model come from the web component rather than from a hand-rolled copy in this file.
Accessibility is the disclosure pattern, not menubar or menuitem roles: those promise a desktop-app keyboard model that links to pages do not deliver. Every trigger is a real button the component wires with aria-expanded, and every item is a real <a> and a natural Tab stop.
Installation
Copy the family into your app. It pulls the shared dropdown-panel base along with it:
puzzle add piece navigation-menu
That base has a runtime dependency — the web component it wraps:
npm install @magic-spells/dropdown-panel
Then merge its stylesheets into your app's style entry. The first is required; the second draws the trigger arrow and the entrance effects, and the stock trigger already carries the arrow hook:
/* app/styles/styles.css */ @import "tailwindcss"; @import "@magic-spells/dropdown-panel/css" layer(components); /* required */ @import "@magic-spells/dropdown-panel/css/effects" layer(components); /* optional */
Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import NavigationMenu from '@/components/ui/NavigationMenu';
<NavigationMenu label="Main">
<NavigationMenu.Item>
<NavigationMenu.Trigger>Products</NavigationMenu.Trigger>
<NavigationMenu.Content columns={ 2 } class="w-max max-w-lg">
<NavigationMenu.Link href="/analytics" label="Analytics" description="Traffic and funnels." />
<NavigationMenu.Link href="/billing" label="Billing" description="Plans and invoices." />
</NavigationMenu.Content>
</NavigationMenu.Item>
<li><NavigationMenu.Link variant="bar" href="/pricing" label="Pricing" /></li>
</NavigationMenu>The <nav> is relative and that is load-bearing: a wide mega panel's host goes position: static so the panel spans the nearest positioned ancestor, and this element is it.
Item is the <li> that keeps the bar valid list markup, with the dropdown inside it — which is fine, because the direct-children rule is about the trigger and panel being direct children of the dropdown component, and the list item sits outside it. Every Item is a dropdown; a plain top-level link needs no member at all — write a bare <li> around a Link with variant="bar".
Mega panel
wide makes the panel span the whole <nav> rather than hang off its trigger — that element is the positioned ancestor, so give it the width you want the panel to have (here flex-1). The Pricing link is current, which is the per-link replacement for the old bar-wide activePath.
Keyboard
All of it lives in the web component; this piece adds no key handling of its own.
Enter / SpaceOn a trigger: toggle its panel.ArrowDown / ArrowUpOn a closed trigger: open and focus the first (or last) link. Inside an open panel: move link focus, wrapping at the ends.Home / EndInside an open panel: first / last link.ArrowRight / ArrowLeftOpen an opens="right" submenu, and close it again returning focus to its trigger.EscapeClose one level and focus its trigger. Only the innermost open panel answers.TabNormal order through the links. A closed panel is inert, so it is skipped.Reference
NavigationMenu
labelaria-label for the <nav>. Defaults to "Main".gapTailwind gap utility for the bar. Defaults to gap-0.5.classMerged onto <nav>, after the bar chrome.NavigationMenu.Item
trigger'hover' | 'click' | 'both' (default), forwarded to the base.arrow'flip' (default) | 'static' | 'none', forwarded to the base.openOptional-controlled and edge-triggered, forwarded. Omit it and the component owns its own state.@show / @hideFired when THIS item's panel opens or closes; a nested submenu's events are filtered out.classMerged onto the <li>.NavigationMenu.Trigger
variant'bar' (default) for top-level chrome, 'card' for an in-panel submenu trigger — a full-width row with the arrow at the trailing edge.arrowtrue (default) renders the [data-dropdown-arrow] hook the effects stylesheet draws into. false drops it.classMerged onto <dropdown-trigger>, after the variant chrome.NavigationMenu.Content
columns1 | 2 | 3 | 4. Default 1, or one column per child on a wide panel.wideA full-width mega panel spanning the <nav>.opens'down' (default) | 'right' for a submenu.align'start' (default) | 'end'. end is left-auto right-0 — pure CSS, no measuring.effect'fade' | 'slide' | 'scale' | 'blur' | 'swing'. Needs the effects stylesheet.classMerged onto <dropdown-panel>, after the layout classes. Never overflow-hidden.NavigationMenu.Link
hrefDefaults to '#'.labelThe text. Falls back to the component's children when unset, which is how you put an icon or a badge in a link.descriptionA second line under the label, clamped to two lines. Card variant in practice.variant'card' (default) for an in-panel link card, 'bar' for a top-level bar link.currenttrue adds aria-current="page" and the active treatment. Per link — there is no bar-wide activePath any more.classMerged onto the <a>.