Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Navigation Menu

    Desktop site navigation with mega menu panels on the Popover API, a sliding active indicator, hover intent, and WAI-ARIA disclosure keyboard support.

    @php
        $products = [
            [
                'label' => 'Components',
                'href' => '/components',
                'description' => '61 accessible building blocks',
            ],
            [
                'label' => 'Templates',
                'href' => '/templates',
                'description' => 'Full pages you can ship today',
            ],
            [
                'label' => 'CLI',
                'href' => '/docs/cli',
                'description' => 'Add components with one command',
            ],
            [
                'label' => 'MCP server',
                'href' => '/docs/mcp',
                'description' => 'Let your editor agent install them',
            ],
        ];
        $developers = [
            [
                'label' => 'Documentation',
                'href' => '/docs',
                'description' => 'Guides and API reference',
            ],
            [
                'label' => 'Registry',
                'href' => '/docs/registry',
                'description' => 'JSON for every component',
            ],
            ['label' => 'Changelog', 'href' => '/changelog', 'description' => 'What shipped this week'],
            ['label' => 'Status', 'href' => '/status', 'description' => 'Registry and docs uptime'],
        ];
        $items = [
            [
                'label' => 'Products',
                'links' => [
                    [
                        'label' => 'Components',
                        'href' => '/components',
                        'description' => '61 accessible building blocks',
                    ],
                    [
                        'label' => 'Templates',
                        'href' => '/templates',
                        'description' => 'Full pages you can ship today',
                    ],
                    [
                        'label' => 'CLI',
                        'href' => '/docs/cli',
                        'description' => 'Add components with one command',
                    ],
                    [
                        'label' => 'MCP server',
                        'href' => '/docs/mcp',
                        'description' => 'Let your editor agent install them',
                    ],
                ],
            ],
            [
                'label' => 'Developers',
                'links' => [
                    [
                        'label' => 'Documentation',
                        'href' => '/docs',
                        'description' => 'Guides and API reference',
                    ],
                    [
                        'label' => 'Registry',
                        'href' => '/docs/registry',
                        'description' => 'JSON for every component',
                    ],
                    ['label' => 'Changelog', 'href' => '/changelog', 'description' => 'What shipped this week'],
                    ['label' => 'Status', 'href' => '/status', 'description' => 'Registry and docs uptime'],
                ],
            ],
            ['label' => 'Pricing', 'href' => '/pricing', 'active' => true],
            ['label' => 'Blog', 'href' => '/blog'],
        ];
    @endphp
    
    <x-markas.navigation-menu :items="$items" />
    import { NavigationMenu } from "@/components/markas/NavigationMenu";
    
    const products = [
      {
        label: "Components",
        href: "/components",
        description: "61 accessible building blocks",
      },
      {
        label: "Templates",
        href: "/templates",
        description: "Full pages you can ship today",
      },
      {
        label: "CLI",
        href: "/docs/cli",
        description: "Add components with one command",
      },
      {
        label: "MCP server",
        href: "/docs/mcp",
        description: "Let your editor agent install them",
      },
    ];
    
    const developers = [
      {
        label: "Documentation",
        href: "/docs",
        description: "Guides and API reference",
      },
      {
        label: "Registry",
        href: "/docs/registry",
        description: "JSON for every component",
      },
      {
        label: "Changelog",
        href: "/changelog",
        description: "What shipped this week",
      },
      {
        label: "Status",
        href: "/status",
        description: "Registry and docs uptime",
      },
    ];
    
    const items = [
      { label: "Products", links: products },
      { label: "Developers", links: developers },
      { label: "Pricing", href: "/pricing", active: true },
      { label: "Blog", href: "/blog" },
    ];
    
    export default function NavigationMenuExample() {
      return <NavigationMenu items={items} />;
    }
    <script setup lang="ts">
    import NavigationMenu from "@/components/markas/NavigationMenu.vue";
    
    const products = [
      {
        label: "Components",
        href: "/components",
        description: "61 accessible building blocks",
      },
      {
        label: "Templates",
        href: "/templates",
        description: "Full pages you can ship today",
      },
      {
        label: "CLI",
        href: "/docs/cli",
        description: "Add components with one command",
      },
      {
        label: "MCP server",
        href: "/docs/mcp",
        description: "Let your editor agent install them",
      },
    ];
    
    const developers = [
      {
        label: "Documentation",
        href: "/docs",
        description: "Guides and API reference",
      },
      {
        label: "Registry",
        href: "/docs/registry",
        description: "JSON for every component",
      },
      {
        label: "Changelog",
        href: "/changelog",
        description: "What shipped this week",
      },
      {
        label: "Status",
        href: "/status",
        description: "Registry and docs uptime",
      },
    ];
    
    const items = [
      { label: "Products", links: products },
      { label: "Developers", links: developers },
      { label: "Pricing", href: "/pricing", active: true },
      { label: "Blog", href: "/blog" },
    ];
    </script>
    
    <template>
      <NavigationMenu :items="items" />
    </template>
    <script lang="ts">
      import NavigationMenu from "$lib/components/markas/NavigationMenu.svelte";
    
      const products = [
        {
          label: "Components",
          href: "/components",
          description: "61 accessible building blocks",
        },
        {
          label: "Templates",
          href: "/templates",
          description: "Full pages you can ship today",
        },
        {
          label: "CLI",
          href: "/docs/cli",
          description: "Add components with one command",
        },
        {
          label: "MCP server",
          href: "/docs/mcp",
          description: "Let your editor agent install them",
        },
      ];
    
      const developers = [
        {
          label: "Documentation",
          href: "/docs",
          description: "Guides and API reference",
        },
        {
          label: "Registry",
          href: "/docs/registry",
          description: "JSON for every component",
        },
        {
          label: "Changelog",
          href: "/changelog",
          description: "What shipped this week",
        },
        {
          label: "Status",
          href: "/status",
          description: "Registry and docs uptime",
        },
      ];
    
      const items = [
        { label: "Products", links: products },
        { label: "Developers", links: developers },
        { label: "Pricing", href: "/pricing", active: true },
        { label: "Blog", href: "/blog" },
      ];
    </script>
    
    <NavigationMenu {items} />
    ---
    import NavigationMenu from "@/components/markas/NavigationMenu.astro";
    
    const products = [
      {
        label: "Components",
        href: "/components",
        description: "61 accessible building blocks",
      },
      {
        label: "Templates",
        href: "/templates",
        description: "Full pages you can ship today",
      },
      {
        label: "CLI",
        href: "/docs/cli",
        description: "Add components with one command",
      },
      {
        label: "MCP server",
        href: "/docs/mcp",
        description: "Let your editor agent install them",
      },
    ];
    
    const developers = [
      {
        label: "Documentation",
        href: "/docs",
        description: "Guides and API reference",
      },
      {
        label: "Registry",
        href: "/docs/registry",
        description: "JSON for every component",
      },
      {
        label: "Changelog",
        href: "/changelog",
        description: "What shipped this week",
      },
      {
        label: "Status",
        href: "/status",
        description: "Registry and docs uptime",
      },
    ];
    
    const items = [
      { label: "Products", links: products },
      { label: "Developers", links: developers },
      { label: "Pricing", href: "/pricing", active: true },
      { label: "Blog", href: "/blog" },
    ];
    ---
    
    <NavigationMenu items={items} />
    import { Component } from "@angular/core";
    import { NavigationMenu } from "./markas/navigation-menu.component";
    
    const products = [
      {
        label: "Components",
        href: "/components",
        description: "61 accessible building blocks",
      },
      {
        label: "Templates",
        href: "/templates",
        description: "Full pages you can ship today",
      },
      {
        label: "CLI",
        href: "/docs/cli",
        description: "Add components with one command",
      },
      {
        label: "MCP server",
        href: "/docs/mcp",
        description: "Let your editor agent install them",
      },
    ];
    
    const developers = [
      {
        label: "Documentation",
        href: "/docs",
        description: "Guides and API reference",
      },
      {
        label: "Registry",
        href: "/docs/registry",
        description: "JSON for every component",
      },
      {
        label: "Changelog",
        href: "/changelog",
        description: "What shipped this week",
      },
      {
        label: "Status",
        href: "/status",
        description: "Registry and docs uptime",
      },
    ];
    
    const items = [
      { label: "Products", links: products },
      { label: "Developers", links: developers },
      { label: "Pricing", href: "/pricing", active: true },
      { label: "Blog", href: "/blog" },
    ];
    
    @Component({
      selector: "markas-example",
      imports: [NavigationMenu],
      template: ` <markas-navigation-menu [items]="items" /> `,
    })
    export default class NavigationMenuFixture {
      protected readonly items = items;
    }

    Examples

    With icons

    Featured cards with glow

    In a site header

    Installation

    npx markasui@latest add navigation-menu

    Usage

    <x-markas.navigation-menu
        :items="[
            ['label' => 'Products', 'featured' => [
                'title' => 'Workflows 2.0',
                'href' => '/workflows',
                'description' => 'Branching, retries, and a visual editor',
            ], 'links' => [
                ['label' => 'Analytics', 'href' => '/analytics', 'description' => 'See where visitors come from', 'icon' => 'M3 3v18h18M7 15l4-4 3 3 5-6'],
                ['label' => 'Automation', 'href' => '/automation', 'description' => 'Run workflows on a schedule'],
            ]],
            ['label' => 'Developers', 'links' => [
                ['label' => 'Documentation', 'href' => '/docs', 'description' => 'Guides and API reference'],
                ['label' => 'Changelog', 'href' => '/changelog', 'description' => 'What shipped this month'],
            ]],
            ['label' => 'Pricing', 'href' => '/pricing', 'active' => true],
        ]"
    />

    Needs Alpine.js. Livewire 3 and 4 already ship Alpine, so there is nothing else to install.

    import { NavigationMenu } from "@/components/markas/NavigationMenu";
    
    <NavigationMenu
      items={[
        {
          label: "Products",
          featured: {
            title: "Workflows 2.0",
            href: "/workflows",
            description: "Branching, retries, and a visual editor",
          },
          links: [
            {
              label: "Analytics",
              href: "/analytics",
              description: "See where visitors come from",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Automation",
              href: "/automation",
              description: "Run workflows on a schedule",
            },
          ],
        },
        {
          label: "Developers",
          links: [
            {
              label: "Documentation",
              href: "/docs",
              description: "Guides and API reference",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "What shipped this month",
            },
          ],
        },
        { label: "Pricing", href: "/pricing", active: true },
      ]}
    />;
    <script setup lang="ts">
    import NavigationMenu from "@/components/markas/NavigationMenu.vue";
    
    const items = [
      {
        label: "Products",
        featured: {
          title: "Workflows 2.0",
          href: "/workflows",
          description: "Branching, retries, and a visual editor",
        },
        links: [
          {
            label: "Analytics",
            href: "/analytics",
            description: "See where visitors come from",
            icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
          },
          {
            label: "Automation",
            href: "/automation",
            description: "Run workflows on a schedule",
          },
        ],
      },
      {
        label: "Developers",
        links: [
          {
            label: "Documentation",
            href: "/docs",
            description: "Guides and API reference",
          },
          {
            label: "Changelog",
            href: "/changelog",
            description: "What shipped this month",
          },
        ],
      },
      { label: "Pricing", href: "/pricing", active: true },
    ];
    </script>
    
    <template>
      <NavigationMenu :items="items" />
    </template>
    <script lang="ts">
      import NavigationMenu from "$lib/components/markas/NavigationMenu.svelte";
    
      const items = [
        {
          label: "Products",
          featured: {
            title: "Workflows 2.0",
            href: "/workflows",
            description: "Branching, retries, and a visual editor",
          },
          links: [
            {
              label: "Analytics",
              href: "/analytics",
              description: "See where visitors come from",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Automation",
              href: "/automation",
              description: "Run workflows on a schedule",
            },
          ],
        },
        {
          label: "Developers",
          links: [
            {
              label: "Documentation",
              href: "/docs",
              description: "Guides and API reference",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "What shipped this month",
            },
          ],
        },
        { label: "Pricing", href: "/pricing", active: true },
      ];
    </script>
    
    <NavigationMenu {items} />
    ---
    import NavigationMenu from "@/components/markas/NavigationMenu.astro";
    
    const items = [
      {
        label: "Products",
        featured: {
          title: "Workflows 2.0",
          href: "/workflows",
          description: "Branching, retries, and a visual editor",
        },
        links: [
          {
            label: "Analytics",
            href: "/analytics",
            description: "See where visitors come from",
            icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
          },
          {
            label: "Automation",
            href: "/automation",
            description: "Run workflows on a schedule",
          },
        ],
      },
      {
        label: "Developers",
        links: [
          {
            label: "Documentation",
            href: "/docs",
            description: "Guides and API reference",
          },
          {
            label: "Changelog",
            href: "/changelog",
            description: "What shipped this month",
          },
        ],
      },
      { label: "Pricing", href: "/pricing", active: true },
    ];
    ---
    
    <NavigationMenu items={items} />

    A small bundled script powers every menu on the page. It also works after view transitions.

    import { Component } from "@angular/core";
    import {
      NavigationMenu,
      type NavigationMenuItem,
    } from "./markas/navigation-menu.component";
    
    @Component({
      selector: "app-site-nav",
      imports: [NavigationMenu],
      template: `<markas-navigation-menu [items]="items" />`,
    })
    export class SiteNav {
      protected readonly items: NavigationMenuItem[] = [
        {
          label: "Products",
          featured: {
            title: "Workflows 2.0",
            href: "/workflows",
            description: "Branching, retries, and a visual editor",
          },
          links: [
            {
              label: "Analytics",
              href: "/analytics",
              description: "See where visitors come from",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Automation",
              href: "/automation",
              description: "Run workflows on a schedule",
            },
          ],
        },
        {
          label: "Developers",
          links: [
            {
              label: "Documentation",
              href: "/docs",
              description: "Guides and API reference",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "What shipped this month",
            },
          ],
        },
        { label: "Pricing", href: "/pricing", active: true },
      ];
    }
    • An entry with links or featured becomes a trigger with a panel. Any other entry is a plain link to href.
    • icon is the d attribute of a 24x24 stroked SVG path, so the same data works in Blade, React, and Vue. Copy it from an icon set such as Lucide.
    • Panels render in the top layer through the Popover API and line up with the left edge of the nav, so switching between triggers swaps content in place. Only one panel is open at a time.
    • Mouse hover opens a panel after a short delay and moves straight to the next trigger once one is open. Clicking a trigger that is already open does not close it, so a click right after hover keeps the panel open. Moving the pointer away, clicking outside, or pressing Escape closes it.
    • The indicator under the triggers follows the open panel and rests on the entry marked active.
    • On narrow screens the top level scrolls horizontally. For a full mobile menu, pair it with Navbar or Drawer.
    • The nav’s accessible name defaults to “Main”. Translate it with navLabel (nav-label in Blade).

    Props

    NameTypeDefaultDescription
    items{ label, href?, active?, links?: { label, href, description?, icon? }[], featured?: { title, href, description? } }[][]Top-level entries. An entry with links or featured becomes a trigger with a panel; otherwise it renders as a plain link to href. icon is the d attribute of a 24x24 stroked SVG path.
    navLabelstringMainAccessible name of the nav element (aria-label).
    idstringautoNav id. Panels use it with a -panel-<index> suffix.

    Accessibility

    • Follows the WAI-ARIA disclosure navigation pattern: each trigger is a button with aria-expanded and aria-controls pointing at its panel, and plain links stay regular links.
    • Enter or Space toggles a panel, Arrow Down opens it and focuses the first link. Tab moves through the panel links in document order.
    • Arrow Left and Arrow Right move between top-level items, Home and End jump to the first and last.
    • Escape closes the panel and returns focus to its trigger. Moving focus outside the entry or clicking outside closes it too.
    • The current page link gets aria-current=page; an active trigger gets aria-current=true. The sliding indicator is decorative and hidden from assistive technology.
    • Hover opens a panel only for mouse pointers, after a short delay, so touch and keyboard users are not surprised. Motion is removed under prefers-reduced-motion.

    Related components

    More navigation components with the same classes in every framework.