Skip to main content
Copy for LLM

Navigation Menu

The <x-wirekit::navigation-menu> component creates a top-level navigation with flyout panels (mega menus). It combines simple links with rich dropdown panels triggered by hover or click, following the WAI-ARIA Disclosure pattern.

Usage

Navigation Menu with Flyout Panels

Items come in two modes:

  • Simple link: pass href -- renders a plain navigation link
  • Flyout trigger: pass trigger -- renders a disclosure button that opens a panel on hover or click
{{-- Simple link -- navigates directly --}}
<x-wirekit::navigation-menu.item href="/pricing">Pricing</x-wirekit::navigation-menu.item>

{{-- Flyout trigger -- opens a panel --}}
<x-wirekit::navigation-menu.item trigger="Products">
    <div>Panel content here</div>
</x-wirekit::navigation-menu.item>

Active State

Mark the currently active item with the active prop on links inside panels:

Active Link in Flyout Panel

In a real Laravel app, pair the active prop with request()->is('…') (or request()->routeIs('…')) so the current page is highlighted automatically — e.g. :active="request()->is('docs*')". Active links receive an accent underline and use aria-current="page".

Inside Livewire's @persist

A menu that Livewire keeps across wire:navigate visits with @persist is not rendered again, so the entry it marked as current would stay the page the reader left. Set track-current and the entry whose link matches the page takes the current state and aria-current after each visit, and when the page moves its own address. It moves the links of the bar itself; a link inside a panel is not part of it. How the match works is described on the sidebar page.

Mega Menu Layout

For complex navigation with multiple columns, use CSS Grid inside the panel:

Mega Menu with Columns

Behavior

  • Hover-to-open: a panel opens as soon as the pointer reaches its trigger
  • Bridge gap: a panel closes 300ms after the pointer leaves its trigger, and stays open when the pointer reaches the panel within that time, so the pointer can cross the gap between the two
  • Floating UI (bundled) positions panels below their triggers with flip and shift; a panel taller than the room on its side of the trigger is capped to that room and its content scrolls, with the trigger in view
  • Click outside closes any open panel
  • Livewire SPA navigation (wire:navigate) automatically closes open panels
  • Transitions use opacity + slide for smooth panel reveal

Building the Panels When They Are Needed

A navigation menu builds every panel with the page, and each panel starts its script, though a reader opens few of them. With lazy on the navigation menu, each panel waits in a <template> until it first opens, by the pointer reaching its trigger, a click or the keyboard. Once built, a panel stays when it closes again, and it opens, takes the focus and closes as a panel built with the page does. A trigger names its panel with aria-controls from the moment the panel is built.

{{-- 1. Each panel is built the first time it opens --}}
<x-wirekit::navigation-menu lazy>
    <x-wirekit::navigation-menu.item trigger="Products">
        <x-wirekit::navigation-menu.link href="/products/wirekit">WireKit</x-wirekit::navigation-menu.link>
    </x-wirekit::navigation-menu.item>
    <x-wirekit::navigation-menu.item href="/pricing">Pricing</x-wirekit::navigation-menu.item>
</x-wirekit::navigation-menu>

To build every navigation menu this way, set it once in the components array of config/wirekit.php:

// config/wirekit.php
'components' => [
    'navigation-menu' => ['lazy' => true],
],

Until a panel has opened, its links are not part of the page: a script that looks for one, and a browser test or a crawler that reads them before the panel opens, find nothing. Leave lazy off for a navigation menu whose panels hold links a search engine should follow from this page.

Props

<x-wirekit::navigation-menu>

Prop Type Default Description
trackCurrent bool false After each wire:navigate visit, mark the entry whose link matches the page as current, with its classes and aria-current, for a menu Livewire keeps across visits with @persist. Needs @wirekitScripts. See Inside Livewire's @persist
lazy bool false Keep each panel out of the page until it first opens; a trigger names its panel from then on. components.navigation-menu.lazy in config/wirekit.php sets the default. See Building the Panels When They Are Needed
scope string|null null Scoped personalization key

<x-wirekit::navigation-menu.item>

Prop Type Default Description
trigger string|null null Label text for flyout trigger (enables panel mode)
triggerLang string|null null The language of trigger where it differs from the page's, written on the trigger's text alone. The panel keeps the page's language, and the id made from the trigger stays as it is
href string|null null URL for simple link mode (no panel)
scope string|null null Scoped personalization key
Prop Type Default Description
href string '#' Link destination
active bool false Highlights as current page (sets aria-current="page")
scope string|null null Scoped personalization key

Sub-Components

Component Purpose
navigation-menu.item Top-level trigger (flyout) or simple link
navigation-menu.link Navigation link inside a flyout panel

Accessibility

  • Navigation wrapper: a <nav> landmark named Main navigation (translated with the app locale). Inside a navigation landmark of the same name, such as a navbar, the menu takes the name Main menu once Alpine starts, so a screen reader's list of landmarks tells the two apart. A name you give the menu, as aria-label, as aria-labelledby or bound with x-bind:aria-label, stays as you give it
  • Flyout triggers: aria-expanded (dynamic) plus aria-controls naming the panel they reveal. Deliberately no aria-haspopup and no role="menu" — this is a disclosure navigation menu: the button reveals a region of links in place, it does not open a menu or a dialog, and announcing one that never appears is worse than announcing nothing
  • Panels: a plain region of links carrying the id the trigger's aria-controls names
  • Links inside panels: standard <a> elements, aria-current="page" when active
  • Every top-level item stays in the tab sequence — no roving tabindex. A bar of navigation links is not a composite widget, so a reader tabs across it the way they tab across any other set of links; the arrow keys below are an addition, not a replacement
  • Hover: a panel opens when the pointer reaches its trigger and stays open while the pointer crosses to the panel, within 300ms
  • Click also works as a fallback for touch devices
  • Chevron indicators on flyout triggers are aria-hidden="true" (decorative)

Keyboard Interaction

Key Context Action
Tab Top-level items Move focus through the navigation items
Arrow Left / Right Top-level items Move focus between navigation items
Home / End Top-level items Jump to first / last navigation item
Enter / Space Flyout trigger Toggle the panel open/closed
Arrow Down Flyout trigger (panel closed) Open panel, focus first link
Tab Open panel Move focus through links inside the panel; from the last one, close the panel and continue at the next top-level item
Shift + Tab First link in an open panel Close the panel and return focus to its trigger
Escape Open panel Close panel, return focus to trigger

The panel is rendered at the end of the document so its position: fixed box escapes any transformed or clipped ancestor, which means the browser's own tab order no longer matches what you see. The component supplies the missing edges itself: Tab off the trigger steps into the panel, and Tab off the panel's last focusable element steps back out to the bar. Anything focusable you put in the slot — a search field, a call-to-action button — joins that sequence in markup order, so there is nothing extra to wire up.

On a right-to-left page, where the items run from the right, Left Arrow and Right Arrow swap: each moves toward the side it names.

Pitfalls

  • Don't use navigation-menu for app-internal commands. It's purpose-built for site navigation (top-level sections). Reach for <x-wirekit::menubar> for File > Edit > View patterns.
  • Don't bury the active page deep in a submenu. WCAG 2.4.8 (Location) is best served by surfacing the current section visibly — keep the top-level link active even when a child is shown.

Design Tokens

Element Token
Bar background --color-wk-bg-elevated
Item text --color-wk-text
Item hover background --color-wk-bg-hover
Panel background --color-wk-bg-elevated
Panel border --color-wk-border / --border-wk-width
Panel radius --radius-wk-lg
Panel shadow --shadow-wk-lg
Panel padding --padding-wk-x-md
Link text --color-wk-text
Link hover bg --color-wk-bg-hover
Link active text --color-wk-accent-text
Link description --color-wk-text-muted
Font family --font-wk-sans
Font size --text-wk-md
Transition --transition-wk-duration

Personalization

This component reads no config/wirekit.php keys — every option is a prop. Style it through the design tokens above, or scope a variant with the scope prop.

An empty 'navigation-menu' => [] block in the config is not an override point: pasting one changes nothing.

Scoped Personalization

<x-wirekit::navigation-menu scope="marketing-nav">
    ...
</x-wirekit::navigation-menu>
// In a service provider's boot() method. A closure receives the shipped classes, so the
// component keeps them; a plain string would replace them outright.
WireKit::scope('marketing-nav', [
    'navigation-menu' => ['classes' => [
        'base' => fn (string $vendor): string => $vendor.' border-b-2 border-[var(--color-wk-border)]',
    ]],
]);

Further Reading

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store