Skip to content
Kappa
Navigation Menu
@dicehub/kappav0.5.0

Navigation Menu

Website and application navigation with links and expandable panels.

Open full-screen example ↗

Installation

Barrel

import { NavigationMenu } from "@dicehub/kappa";

Granular

import { NavigationMenu } from "@dicehub/kappa/components/navigation-menu";

Usage

Put each link or dropdown in an Item with a unique value. Use Trigger to open Content, and give Root an aria-label.

Set current on the active link. Use size="sm" for a compact menu. Bind v-model:value to control the open panel; set it to '' to close.

Composition

NavigationMenu.Root
├── NavigationMenu.List
│   ├── NavigationMenu.Item
│   │   ├── NavigationMenu.Trigger
│   │   └── NavigationMenu.Content
│   │       └── NavigationMenu.Link
│   ├── NavigationMenu.Item
│   │   └── NavigationMenu.Link
│   └── NavigationMenu.Indicator (optional)
└── NavigationMenu.ViewportPositioner
    └── NavigationMenu.Viewport

Put ViewportPositioner inside Root, after List. Keep each Content inside its Item. Allow panels to extend beyond the navigation container.

Examples

Compact

Use size="sm" for smaller controls and tighter spacing.

Click to open

Use v-model:value to open or close a panel. Disable hover to open panels only on click.

Vertical

Set orientation="vertical" and align="start" to open panels beside the list. Arrows point toward the panels.

Use links without panels. Set current on the active page link.

Right to left

Wrap the menu in DirectionProvider and set an RTL locale.

Router links

Use asChild with your router link. Set current from the active route.

<NavigationMenu.Link as-child :current="route.path === '/projects'">
  <RouterLink to="/projects">Projects</RouterLink>
</NavigationMenu.Link>

Accessibility

  • The root is a navigation landmark, triggers are buttons, and destinations are links. There are no menuitem roles on page links.
  • Tab moves through the navigation. Left and Right arrows move between horizontal triggers and links. Vertical navigation uses Up and Down. Home and End move to the first and last item.
  • Enter or Space toggles a trigger. Down arrow enters an open horizontal panel. In vertical mode, Right enters the panel, or Left in right-to-left mode.
  • Escape closes the panel and restores trigger focus. Outside interaction dismisses it. Disabled triggers are skipped.
  • Touch users can tap triggers. Motion is disabled when reduced motion is requested.

API Reference

Use v-model:value to control the open panel, or defaultValue to select one initially. An empty string closes the menu. Initially selected panels open after mount. The root emits update:value and valueChange.

  • Root and RootProvider accept size="sm | md", default md. openDelay defaults to 200 ms; closeDelay defaults to 300 ms.
  • Trigger adds showIndicator, default true. Supply your own chevron when using asChild.
  • Link supports current, closeOnClick (default true), and the cancelable select event. Prevent that event to keep the panel open.
  • ViewportPositioner supports align="start | center | end", default center.
  • Panels stay mounted while closed. Lazy mounting and unmount-on-exit are not supported.
  • Set --kappa-navigation-menu-content-width on Content to change panel width. Set --kappa-navigation-menu-z-index on Root to change stacking.

All compound parts also have named exports, such as NavigationMenuTrigger. Advanced compositions can use RootProvider, Context, useNavigationMenu, and useNavigationMenuContext. Optional indicators include Indicator, ItemIndicator, and Arrow.