Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Navigation Menu

    Navigasi situs desktop dengan panel mega menu berbasis Popover API, indikator aktif yang meluncur, jeda hover, dan keyboard pola disclosure WAI-ARIA.

    @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;
    }

    Contoh

    Dengan ikon

    Kartu sorotan bercahaya

    Di header situs

    Instalasi

    npx markasui@latest add navigation-menu

    Pemakaian

    <x-markas.navigation-menu
        nav-label="Utama"
        :items="[
            ['label' => 'Produk', 'featured' => [
                'title' => 'Workflow 2.0',
                'href' => '/workflow',
                'description' => 'Percabangan, coba ulang, dan editor visual',
            ], 'links' => [
                ['label' => 'Analitik', 'href' => '/analitik', 'description' => 'Lihat asal pengunjung', 'icon' => 'M3 3v18h18M7 15l4-4 3 3 5-6'],
                ['label' => 'Otomasi', 'href' => '/otomasi', 'description' => 'Jalankan workflow terjadwal'],
            ]],
            ['label' => 'Developer', 'links' => [
                ['label' => 'Dokumentasi', 'href' => '/docs', 'description' => 'Panduan dan referensi API'],
                ['label' => 'Changelog', 'href' => '/changelog', 'description' => 'Yang rilis bulan ini'],
            ]],
            ['label' => 'Harga', 'href' => '/harga', 'active' => true],
        ]"
    />

    Butuh Alpine.js. Livewire 3 dan 4 sudah membawa Alpine, jadi tidak perlu dipasang lagi.

    import { NavigationMenu } from "@/components/markas/NavigationMenu";
    
    <NavigationMenu
      navLabel="Utama"
      items={[
        {
          label: "Produk",
          featured: {
            title: "Workflow 2.0",
            href: "/workflow",
            description: "Percabangan, coba ulang, dan editor visual",
          },
          links: [
            {
              label: "Analitik",
              href: "/analitik",
              description: "Lihat asal pengunjung",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Otomasi",
              href: "/otomasi",
              description: "Jalankan workflow terjadwal",
            },
          ],
        },
        {
          label: "Developer",
          links: [
            {
              label: "Dokumentasi",
              href: "/docs",
              description: "Panduan dan referensi API",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "Yang rilis bulan ini",
            },
          ],
        },
        { label: "Harga", href: "/harga", active: true },
      ]}
    />;
    <script setup lang="ts">
    import NavigationMenu from "@/components/markas/NavigationMenu.vue";
    
    const items = [
      {
        label: "Produk",
        featured: {
          title: "Workflow 2.0",
          href: "/workflow",
          description: "Percabangan, coba ulang, dan editor visual",
        },
        links: [
          {
            label: "Analitik",
            href: "/analitik",
            description: "Lihat asal pengunjung",
            icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
          },
          {
            label: "Otomasi",
            href: "/otomasi",
            description: "Jalankan workflow terjadwal",
          },
        ],
      },
      {
        label: "Developer",
        links: [
          {
            label: "Dokumentasi",
            href: "/docs",
            description: "Panduan dan referensi API",
          },
          {
            label: "Changelog",
            href: "/changelog",
            description: "Yang rilis bulan ini",
          },
        ],
      },
      { label: "Harga", href: "/harga", active: true },
    ];
    </script>
    
    <template>
      <NavigationMenu nav-label="Utama" :items="items" />
    </template>
    <script lang="ts">
      import NavigationMenu from "$lib/components/markas/NavigationMenu.svelte";
    
      const items = [
        {
          label: "Produk",
          featured: {
            title: "Workflow 2.0",
            href: "/workflow",
            description: "Percabangan, coba ulang, dan editor visual",
          },
          links: [
            {
              label: "Analitik",
              href: "/analitik",
              description: "Lihat asal pengunjung",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Otomasi",
              href: "/otomasi",
              description: "Jalankan workflow terjadwal",
            },
          ],
        },
        {
          label: "Developer",
          links: [
            {
              label: "Dokumentasi",
              href: "/docs",
              description: "Panduan dan referensi API",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "Yang rilis bulan ini",
            },
          ],
        },
        { label: "Harga", href: "/harga", active: true },
      ];
    </script>
    
    <NavigationMenu navLabel="Utama" {items} />
    ---
    import NavigationMenu from "@/components/markas/NavigationMenu.astro";
    
    const items = [
      {
        label: "Produk",
        featured: {
          title: "Workflow 2.0",
          href: "/workflow",
          description: "Percabangan, coba ulang, dan editor visual",
        },
        links: [
          {
            label: "Analitik",
            href: "/analitik",
            description: "Lihat asal pengunjung",
            icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
          },
          {
            label: "Otomasi",
            href: "/otomasi",
            description: "Jalankan workflow terjadwal",
          },
        ],
      },
      {
        label: "Developer",
        links: [
          {
            label: "Dokumentasi",
            href: "/docs",
            description: "Panduan dan referensi API",
          },
          {
            label: "Changelog",
            href: "/changelog",
            description: "Yang rilis bulan ini",
          },
        ],
      },
      { label: "Harga", href: "/harga", active: true },
    ];
    ---
    
    <NavigationMenu navLabel="Utama" items={items} />

    Satu script kecil yang dibundel menghidupkan setiap menu di halaman, termasuk setelah view transition.

    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 navLabel="Utama" [items]="items" />`,
    })
    export class SiteNav {
      protected readonly items: NavigationMenuItem[] = [
        {
          label: "Produk",
          featured: {
            title: "Workflow 2.0",
            href: "/workflow",
            description: "Percabangan, coba ulang, dan editor visual",
          },
          links: [
            {
              label: "Analitik",
              href: "/analitik",
              description: "Lihat asal pengunjung",
              icon: "M3 3v18h18M7 15l4-4 3 3 5-6",
            },
            {
              label: "Otomasi",
              href: "/otomasi",
              description: "Jalankan workflow terjadwal",
            },
          ],
        },
        {
          label: "Developer",
          links: [
            {
              label: "Dokumentasi",
              href: "/docs",
              description: "Panduan dan referensi API",
            },
            {
              label: "Changelog",
              href: "/changelog",
              description: "Yang rilis bulan ini",
            },
          ],
        },
        { label: "Harga", href: "/harga", active: true },
      ];
    }
    • Entri dengan links atau featured menjadi pemicu dengan panel. Entri lain menjadi link biasa ke href.
    • icon adalah atribut d dari path SVG bergaris 24x24, jadi data yang sama berlaku di Blade, React, dan Vue. Salin dari set ikon seperti Lucide.
    • Panel tampil di top layer lewat Popover API dan rata dengan tepi kiri nav, jadi berpindah antar pemicu menukar isi di tempat yang sama. Hanya satu panel yang terbuka.
    • Hover mouse membuka panel setelah jeda singkat dan langsung pindah ke pemicu berikutnya bila sudah ada yang terbuka. Klik pada pemicu yang sudah terbuka tidak menutupnya, jadi klik setelah hover membuat panel tetap terbuka. Kursor yang pergi, klik di luar, atau Escape menutupnya.
    • Indikator di bawah pemicu mengikuti panel yang terbuka dan kembali ke entri bertanda active.
    • Di layar sempit tingkat atas bergulir horizontal. Untuk menu mobile lengkap, pasangkan dengan Navbar atau Drawer.
    • Nama aksesibel nav default “Main”. Terjemahkan lewat navLabel (nav-label di Blade).

    Props

    NamaTipeDefaultKeterangan
    items{ label, href?, active?, links?: { label, href, description?, icon? }[], featured?: { title, href, description? } }[][]Entri tingkat atas. Entri dengan links atau featured menjadi pemicu dengan panel; selain itu tampil sebagai link biasa ke href. icon adalah atribut d dari path SVG bergaris 24x24.
    navLabelstringMainNama aksesibel elemen nav (aria-label). Default "Main", isi misalnya "Utama" untuk situs berbahasa Indonesia.
    idstringautoId nav. Panel memakai id ini dengan akhiran -panel-<indeks>.

    Aksesibilitas

    • Mengikuti pola navigasi disclosure WAI-ARIA: setiap pemicu adalah button dengan aria-expanded dan aria-controls ke panelnya, dan link biasa tetap link biasa.
    • Enter atau Spasi membuka dan menutup panel, panah bawah membukanya dan memfokuskan link pertama. Tab berpindah antar link panel sesuai urutan dokumen.
    • Panah kiri dan kanan berpindah antar item tingkat atas, Home dan End ke item pertama dan terakhir.
    • Escape menutup panel dan mengembalikan fokus ke pemicunya. Fokus yang keluar dari entri atau klik di luar juga menutupnya.
    • Link halaman saat ini mendapat aria-current=page; pemicu aktif mendapat aria-current=true. Indikator yang meluncur hanya dekorasi dan disembunyikan dari teknologi asistif.
    • Hover membuka panel hanya untuk pointer mouse, setelah jeda singkat, supaya pengguna sentuh dan keyboard tidak terkejut. Animasi dimatikan saat prefers-reduced-motion.

    Komponen terkait

    Komponen navigasi lain dengan class yang sama di setiap framework.