Product navigation
Group several destination links under a discoverable top-level section.
Components / Navigation
Semantic website navigation with disclosure content, active links, and managed keyboard focus.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add navigation-menuImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import NavigationMenu from './components/ui/navigation-menu/NavigationMenu.vue'
import NavigationMenuContent from './components/ui/navigation-menu/NavigationMenuContent.vue'
import NavigationMenuItem from './components/ui/navigation-menu/NavigationMenuItem.vue'
import NavigationMenuLink from './components/ui/navigation-menu/NavigationMenuLink.vue'
import NavigationMenuList from './components/ui/navigation-menu/NavigationMenuList.vue'
import NavigationMenuTrigger from './components/ui/navigation-menu/NavigationMenuTrigger.vue'
import NavigationMenuViewport from './components/ui/navigation-menu/NavigationMenuViewport.vue'
</script>
<template>
<NavigationMenu label="Primary navigation">
<NavigationMenuList>
<NavigationMenuItem value="learn">
<NavigationMenuTrigger>Learn</NavigationMenuTrigger>
<NavigationMenuContent>
<div class="grid gap-3 p-4">
<NavigationMenuLink href="https://ui.weini.lu/guides/getting-started">
Getting started
</NavigationMenuLink>
<NavigationMenuLink href="https://ui.weini.lu/guides/accessibility">
Accessibility
</NavigationMenuLink>
</div>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
<NavigationMenuViewport />
</NavigationMenu>
</template>Dropdown content uses a compact 4px outer inset. Links keep 12px inline padding, 44px minimum row targets, and an 8px gap between an icon and its label stack.
Group several destination links under a discoverable top-level section.
Offer a compact menu of guides while keeping direct links available.
Use the viewport for a shared disclosure surface and mark the active page.
<script setup lang="ts">
import NavigationMenu from './components/ui/navigation-menu/NavigationMenu.vue'
import NavigationMenuContent from './components/ui/navigation-menu/NavigationMenuContent.vue'
import NavigationMenuItem from './components/ui/navigation-menu/NavigationMenuItem.vue'
import NavigationMenuLink from './components/ui/navigation-menu/NavigationMenuLink.vue'
import NavigationMenuList from './components/ui/navigation-menu/NavigationMenuList.vue'
import NavigationMenuTrigger from './components/ui/navigation-menu/NavigationMenuTrigger.vue'
import NavigationMenuViewport from './components/ui/navigation-menu/NavigationMenuViewport.vue'
</script>
<template>
<NavigationMenu label="Primary navigation">
<NavigationMenuList>
<NavigationMenuItem value="learn">
<NavigationMenuTrigger>Learn</NavigationMenuTrigger>
<NavigationMenuContent>
<div class="grid gap-3 p-4">
<NavigationMenuLink href="https://ui.weini.lu/guides/getting-started">
Getting started
</NavigationMenuLink>
<NavigationMenuLink href="https://ui.weini.lu/guides/accessibility">
Accessibility
</NavigationMenuLink>
</div>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
<NavigationMenuViewport />
</NavigationMenu>
</template>A second disclosure can contain another set of semantic links.
<script setup lang="ts">
import NavigationMenu from './components/ui/navigation-menu/NavigationMenu.vue'
import NavigationMenuContent from './components/ui/navigation-menu/NavigationMenuContent.vue'
import NavigationMenuItem from './components/ui/navigation-menu/NavigationMenuItem.vue'
import NavigationMenuLink from './components/ui/navigation-menu/NavigationMenuLink.vue'
import NavigationMenuList from './components/ui/navigation-menu/NavigationMenuList.vue'
import NavigationMenuTrigger from './components/ui/navigation-menu/NavigationMenuTrigger.vue'
import NavigationMenuViewport from './components/ui/navigation-menu/NavigationMenuViewport.vue'
</script>
<template>
<NavigationMenu label="Guides" orientation="horizontal">
<NavigationMenuList>
<NavigationMenuItem value="guides">
<NavigationMenuTrigger>Guides</NavigationMenuTrigger>
<NavigationMenuContent>
<div class="grid gap-2 p-4">
<NavigationMenuLink href="/guides/getting-started">Getting started</NavigationMenuLink>
<NavigationMenuLink href="/guides/accessibility">Accessibility</NavigationMenuLink>
</div>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
<NavigationMenuViewport />
</NavigationMenu>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
valuemodel | string | undefined | Not set | Value represented by this control or option. |
defaultValueprop | string | undefined | Not set | Starting value when the parent does not control the value. |
orientationprop | NavigationMenuOrientation | undefined | "horizontal" | Arrange items horizontally or vertically. |
dirprop | NavigationMenuDirection | undefined | "ltr" | Set the text direction used for keyboard and layout behavior. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
labelprop | string | undefined | Not set | Visible or accessible name for this item. |
valueChangeevent | [value: string | undefined] | — | Emitted after this value or state changes. |
update:valueevent | [value: string | undefined] | — | Requests a new value value from the parent. |
defaultslot | (props: { value: string | undefined; setValue: (value: string | undefined) => void; }) => unknown | Required | Content shown inside NavigationMenu. |
closeexposed | () => void | — | Close this component from application code. |
focusexposed | () => void | — | Move keyboard focus to this control. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
forceMountprop | boolean | undefined | false | Keep the content mounted even when it is closed. |
defaultslot | { close: () => void; } | Optional | Content shown inside NavigationMenuContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | { value: string; } | Optional | Content shown inside NavigationMenuIndicator. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
valueprop | string | Required | Value represented by this control or option. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
defaultslot | {} | Optional | Content shown inside NavigationMenuItem. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
hrefprop | string | undefined | Not set | URL to navigate to when this link is activated. |
asprop | Component | "a" | undefined | "a" | Choose the HTML element or Vue component used for this control. |
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
activeprop | boolean | undefined | Not set | Mark this item as the current active item. |
ariaCurrentprop | NavigationMenuAriaCurrent | undefined | Not set | Identify the current item to assistive technology. |
defaultslot | (props: { active: boolean; }) => unknown | Required | Content shown inside NavigationMenuLink. |
iconslot | ((props: { active: boolean; }) => unknown) | undefined | Optional | Content for the icon area of NavigationMenuLink. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside NavigationMenuList. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
defaultslot | { open: boolean; } | Optional | Content shown inside NavigationMenuTrigger. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside NavigationMenuViewport. |
// packages/frameworks/vue/components/navigation-menu/types.ts
import type { Component } from 'vue'
export type NavigationMenuOrientation = 'horizontal' | 'vertical'
export type NavigationMenuDirection = 'ltr' | 'rtl'
export type NavigationMenuAriaCurrent = 'page' | 'step' | 'location' | 'date' | 'time'
export interface NavigationMenuProps {
value?: string
defaultValue?: string
orientation?: NavigationMenuOrientation
dir?: NavigationMenuDirection
disabled?: boolean
label?: string
}
export interface NavigationMenuItemProps {
value: string
disabled?: boolean
}
export interface NavigationMenuTriggerProps {
disabled?: boolean
}
export interface NavigationMenuContentProps {
forceMount?: boolean
}
export interface NavigationMenuLinkProps {
href?: string
as?: 'a' | Component
asChild?: boolean
active?: boolean
ariaCurrent?: NavigationMenuAriaCurrent
}