Navigation Menu
A collection of links for navigating websites.
Preview
Installation
npx sigma-ui@latest add navigation-menuUsage
<script setup lang="ts">
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from '@/components/ui/navigation-menu';
</script>
<template>
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Item One</NavigationMenuTrigger>
<NavigationMenuContent>
<NavigationMenuLink href="/docs">
Link
</NavigationMenuLink>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</template>- An item with a
<NavigationMenuTrigger>opens its<NavigationMenuContent>panel on hover or click. - An item with only a
<NavigationMenuLink>renders a top-level link.
Examples
Link Component
To render a router link such as Nuxt's <NuxtLink />, use as-child and apply the trigger styles with navigationMenuTriggerStyle().
<script setup lang="ts">
import {
NavigationMenuItem,
NavigationMenuLink,
navigationMenuTriggerStyle,
} from '@/components/ui/navigation-menu';
</script>
<template>
<NavigationMenuItem>
<NavigationMenuLink
as-child
:class="navigationMenuTriggerStyle()"
>
<NuxtLink to="/docs">
Documentation
</NuxtLink>
</NavigationMenuLink>
</NavigationMenuItem>
</template>API Reference
NavigationMenu
Props
| Prop | Type | Default |
|---|---|---|
modelValueThe controlled value of the menu item to activate. Can be used as | string | - |
defaultValueThe value of the menu item that should be active when initially rendered. Use when you do not need to control the value state. | string | - |
dirThe reading direction of the combobox when applicable. If omitted, inherits globally from | Direction$3 | - |
orientationThe orientation of the menu. | Orientation | - |
delayDurationThe duration from when the pointer enters the trigger until the tooltip gets opened. | number | 200 |
skipDelayDurationHow much time a user has to enter another trigger without incurring a delay again. | number | 300 |
disableClickTriggerIf | boolean | false |
disableHoverTriggerIf | boolean | false |
disablePointerLeaveCloseIf | boolean | false |
unmountOnHideWhen | boolean | `true` |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
update:modelValueEvent handler called when the value changes. | [value: string] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
NavigationMenuList
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
NavigationMenuItem
Props
| Prop | Type | Default |
|---|---|---|
valueA unique value that associates the item with an active value when the navigation menu is controlled. This prop is managed automatically when uncontrolled. | string | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
NavigationMenuTrigger
Props
| Prop | Type | Default |
|---|---|---|
disabledWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
NavigationMenuContent
Props
| Prop | Type | Default |
|---|---|---|
forceMountUsed to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries. | boolean | - |
disableOutsidePointerEventsWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
escapeKeyDownEvent handler called when the escape key is down. Can be prevented. | [event: KeyboardEvent] |
pointerDownOutsideEvent handler called when a | [event: PointerDownOutsideEvent] |
focusOutsideEvent handler called when the focus moves outside of the | [event: FocusOutsideEvent] |
interactOutsideEvent handler called when an interaction happens outside the | [event: PointerDownOutsideEvent | FocusOutsideEvent] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
NavigationMenuLink
Props
| Prop | Type | Default |
|---|---|---|
activeUsed to identify the link as the currently active page. | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
selectEvent handler called when the user selects a link (via mouse or keyboard). Calling | [payload: CustomEvent<{ originalEvent: Event; }>] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
Adheres to the Disclosure Navigation Menu WAI-ARIA example. Reka UI manages focus and the aria-expanded state of the triggers.
| Key | Description |
|---|---|
| Space | When focus is on a trigger, opens its content. |
| Enter | When focus is on a trigger, opens its content. |
| Tab | Moves focus to the next focusable element. |
| ArrowDown | When focus is on a trigger in a horizontal menu, opens its content and focuses the first link. Moves focus to the next item in a vertical menu. |
| ArrowUp | Moves focus to the previous item in a vertical menu. |
| ArrowRight | Moves focus to the next trigger or link in a horizontal menu. |
| ArrowLeft | Moves focus to the previous trigger or link in a horizontal menu. |
| Home | Moves focus to the first trigger or link. |
| End | Moves focus to the last trigger or link. |
| Esc | Closes the open content and moves focus to its trigger. |