9.5k

Mega Menu

PreviousNext

Full-width dropdown navigation menu for mega-menu panels that span the viewport width.

Installation

pnpm dlx @frontic/ui add mega-menu

Usage

<script setup lang="ts">
import {
  MegaMenu,
  MegaMenuContent,
  MegaMenuItem,
  MegaMenuLink,
  MegaMenuList,
  MegaMenuTrigger,
} from '@/components/ui/mega-menu'
</script>

<template>
  <MegaMenu>
    <MegaMenuList>
      <MegaMenuItem>
        <MegaMenuTrigger>
          Category
        </MegaMenuTrigger>
        <MegaMenuContent>
          <!-- Full-width mega-menu panel content -->
        </MegaMenuContent>
      </MegaMenuItem>
    </MegaMenuList>
  </MegaMenu>
</template>

About

The Mega Menu component provides full-width dropdown panels for navigation, built on reka-ui NavigationMenu primitives.

Unlike the standard NavigationMenu (which renders compact, viewport-measured dropdowns), the Mega Menu uses position: fixed to span the full viewport width — ideal for store navigation headers with featured images, link sections, and promotional content.

Key differences from NavigationMenu

  • Full-width panels: Content spans the entire viewport width using fixed positioning
  • Auto top positioning: Automatically calculates the top offset from the root element's bottom edge
  • No viewport: Does not use NavigationMenuViewport — content is positioned directly
  • Headless trigger: No built-in chevron or indicator — the consumer decides the trigger style

Components

ComponentDescription
MegaMenuRoot wrapper. Provides positioning context via inject.
MegaMenuListContainer for menu items.
MegaMenuItemIndividual menu item wrapper.
MegaMenuTriggerTrigger button. Slot-only — add your own chevron or indicator.
MegaMenuContentFull-width fixed panel with fade + zoom animations.
MegaMenuLinkLink wrapper with proper navigation semantics.

Composable

The useMegaMenu composable is available for advanced use cases:

import { useMegaMenu } from '@/components/ui/mega-menu'

const { megaMenuTop, updateTop } = useMegaMenu()
  • megaMenuTop — Reactive ref with the calculated top position
  • updateTop() — Recalculate the top position (useful for sticky headers)