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.ViewportPut 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.
Direct links
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.
RootandRootProvideracceptsize="sm | md", defaultmd.openDelaydefaults to 200 ms;closeDelaydefaults to 300 ms.TriggeraddsshowIndicator, defaulttrue. Supply your own chevron when usingasChild.Linksupportscurrent,closeOnClick(default true), and the cancelableselectevent. Prevent that event to keep the panel open.ViewportPositionersupportsalign="start | center | end", defaultcenter.- Panels stay mounted while closed. Lazy mounting and unmount-on-exit are not supported.
- Set
--kappa-navigation-menu-content-widthon Content to change panel width. Set--kappa-navigation-menu-z-indexon 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.