Navigation Menu
Build navigation links with flyouts or expandable groups.
Demos
Usage
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Flyouts sit 2px from their trigger. Flyout links stack their title above the description. The hover highlight slides between top-level controls in 180ms and follows keyboard focus. Hovering a link without children closes the previous flyout. Reduced motion disables the slide.
Installation
Complete the shared installation. Copy NavigationMenu.vue and index.ts into app/components/ui/navigation-menu/.
<script setup lang="ts">
import { Meter as Primitive } from 'akaza-ui'
import { computed, useAttrs } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import { meterVariants, resolveMeterVariants, type MeterProps, type MeterSlots } from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<MeterProps>(), {
min: undefined,
max: undefined,
low: undefined,
high: undefined,
optimum: undefined,
label: undefined,
ariaLabel: undefined,
ariaLabelledby: undefined,
ariaValueText: undefined,
locale: undefined,
formatOptions: undefined,
getAriaValueText: undefined,
getValueLabel: undefined,
ui: undefined,
})
defineSlots<MeterSlots>()
const attrs = useAttrs()
const styles = computed(() => meterVariants(resolveMeterVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'root' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, size: _size, ...native } = props
return native
})
</script>
<template>
<component :is="Primitive" v-bind="{ ...primitiveProps, ...attrs }" :ui="mergedUi">
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof MeterSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Variants and defaults
| Prop | Values | Default |
|---|---|---|
size | xs, sm, md, lg, xl | sm |
Models
| Model | Type | Default | Description |
|---|---|---|---|
v-model | string | null | defaultValue | Selected leaf value. Falls back to a string to, href, then label. |
v-model:open | string | null | null | Active horizontal or side flyout item. |
v-model:expanded | string[] | defaultExpanded and item defaults | Expanded inline item values. Multiple branches may remain open. |
Props
Use highlight-mode="selection" to keep the shared indicator on the current item; the default hover mode follows pointer and focus movement. Use selection-hover to retain selection and track hover with a separate marker. Sidebar uses these modes for its line and rail designs.
| Prop | Type | Default | Description |
|---|---|---|---|
items | NavigationMenuItem[] | required | Top-level navigation items. |
defaultValue | string | null | null | Initially selected value when v-model is uncontrolled. |
orientation | "horizontal" | "vertical" | "horizontal" | Top-level layout and keyboard direction. |
contentMode | "auto" | "flyout" | "inline" | "auto" | Child presentation. Auto uses horizontal flyouts, vertical inline expansion, and collapsed vertical side flyouts. |
collapsed | boolean | false | Enables icon-rail behavior and automatic side flyouts for vertical navigation. |
tooltip | boolean | false | Shows accessible flyout labels for collapsed items without children. |
defaultExpanded | string[] | [] | Initially expanded inline item values. |
loop | boolean | true | Arrow-key focus wraps. |
dir | "ltr" | "rtl" | "ltr" | Horizontal direction and vertical flyout side. |
disabled | boolean | false | Disables trigger interaction. |
openDelay | number | 80 | Pointer-open delay in milliseconds. |
closeDelay | number | 150 | Pointer-close delay in milliseconds. |
sideOffset | number | 2 | Distance between a flyout and its trigger. |
teleport | string | false | automatic | Flyout Teleport target. Defaults to body for collapsed vertical navigation and no Teleport otherwise. |
ariaLabel | string | "Primary" | Accessible nav label. |
ui | NavigationMenuUi | — | Classes for structural parts. |
Slots
| Slot | Props | Description |
|---|---|---|
trigger | NavigationMenuSlotProps | Top-level flyout trigger content. |
link | NavigationMenuSlotProps | Top-level direct-link content. |
item | NavigationMenuSlotProps | Flyout item or complete vertical row content. |
item-leading | NavigationMenuSlotProps | Leading icon/content for generated rows. |
item-label | NavigationMenuSlotProps | Generated label replacement. |
item-trailing | NavigationMenuSlotProps | Trailing action or metadata. |
child-indicator | NavigationMenuSlotProps | Expansion indicator for child-bearing items. |
[item.slot] | NavigationMenuSlotProps | Per-item complete-content override. |
NavigationMenuSlotProps exposes item, isOpen, isActive, depth, collapsed, and a native-handler-safe toggle action.
Events
| Event | Payload | Description |
|---|---|---|
open-change | (value: string | null, details) | Fired before active flyout changes. |
expanded-change | (values: string[], details) | Fired before inline expansion changes. Details include item and expanded; call details.cancel() to reject it. |
value-change | (value, details) | Fired before the selected value changes. Details include item; call details.cancel() to reject it. |
select | (item, details) | Fired when a link/item is selected. |
Keyboard
| Key | Behavior |
|---|---|
ArrowRight / ArrowLeft | Move between horizontal items. In vertical inline mode, expand/collapse a branch or return to its parent. In vertical flyout mode, open toward the reading direction. |
ArrowDown / ArrowUp | Move through vertical inline rows, vertical flyout triggers, or flyout links. |
ArrowDown / Enter / Space | Open a horizontal flyout item. Enter/Space also toggles inline disclosure buttons. |
Home / End | Focus first/last enabled top-level item. |
| Character keys | Typeahead across flyout triggers. |
ArrowDown / ArrowUp in flyout | Move through enabled flyout links. |
Escape | Close the active flyout. |