NavigationMenu 네비게이션 메뉴
가로 또는 세로로 표시할 수 있는 링크 목록 컴포넌트예요. 하위 메뉴·칩·툴팁·팝오버·커스텀 슬롯까지 지원해 다양한 내비게이션 구조를 만들 수 있어요.
출처: Nuxt UI
본문
가로 또는 세로로 표시할 수 있는 링크 목록이에요.
사용법 (Usage)
NavigationMenu 컴포넌트를 사용해 링크 목록을 가로 또는 세로로 표시해요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
},
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
])
</script>
<template>
<UNavigationMenu :items="items" />
</template>
Items
items prop에 다음 속성을 가진 객체 배열을 전달해요.
label?: stringicon?: stringavatar?: AvatarPropsbadge?: string | number | BadgePropschip?: boolean | ChipPropstooltip?: TooltipPropspopover?: PopoverPropstrailingIcon?: stringtype?: 'label' | 'trigger' | 'link'defaultOpen?: booleanopen?: booleanvalue?: stringdisabled?: booleanslot?: stringonSelect?: (e: Event) => voidchildren?: NavigationMenuChildItem[]class?: anyui?: { linkLeadingAvatarSize?: ClassNameValue, linkLeadingAvatar?: ClassNameValue, linkLeadingIcon?: ClassNameValue, linkLeadingChipSize?: ClassNameValue, linkLabel?: ClassNameValue, linkLabelExternalIcon?: ClassNameValue, linkTrailing?: ClassNameValue, linkTrailingBadgeSize?: ClassNameValue, linkTrailingBadge?: ClassNameValue, linkTrailingIcon?: ClassNameValue, label?: ClassNameValue, link?: ClassNameValue, content?: ClassNameValue, childList?: ClassNameValue, childLabel?: ClassNameValue, childItem?: ClassNameValue, childLink?: ClassNameValue, childLinkIcon?: ClassNameValue, childLinkWrapper?: ClassNameValue, childLinkLabel?: ClassNameValue, childLinkLabelExternalIcon?: ClassNameValue, childLinkDescription?: ClassNameValue }
Link 컴포넌트의 to, target 등 어떤 속성이든 전달할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
},
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
])
</script>
<template>
<UNavigationMenu :items="items" class="w-full justify-center" />
</template>
[!NOTE]
itemsprop에 배열의 배열을 전달해 항목 그룹을 표시할 수도 있어요.
[!TIP]
각 항목에
children객체 배열을 넣어 하위 메뉴를 만들 수도 있어요.
label: stringdescription?: stringicon?: stringonSelect?: (e: Event) => voidclass?: any
Orientation
orientation prop으로 NavigationMenu의 방향을 바꿀 수 있어요.
[!NOTE]
방향이
vertical일 때는 각 그룹을 표시하기 위해 Accordion 컴포넌트가 사용돼요.open과defaultOpen속성으로 각 항목의 열림 상태를 제어하고,collapsible과typeprop으로 동작을 바꿀 수 있어요.
[!NOTE]
방향이
vertical이고 메뉴가collapsed가 아닐 때는 하위 항목이 재귀적으로 항목으로 렌더링되므로ui.link가 스타일을 적용해요.ui.childLink는horizontal방향의content와collapsed일 때의 popover에만 적용돼요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Links",
type: "label"
},
{
label: "Guide",
icon: "i-lucide-book-open",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
type: "trigger",
active: true,
defaultOpen: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu orientation="vertical" :items="items" class="data-[orientation=vertical]:w-48" />
</template>
[!NOTE]
방향이
horizontal일 때는 그룹 사이에 간격이 생기고,vertical일 때는 그룹이 분리돼요.
Collapsed
vertical 방향에서 collapsed prop으로 NavigationMenu를 접을 수 있어요. 예를 들어 사이드바에서 유용해요.
[!NOTE]
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Links",
type: "label"
},
{
label: "Guide",
icon: "i-lucide-book-open",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu collapsed :tooltip="false" :popover="false" orientation="vertical" :items="items" />
</template>
Highlight
highlight prop으로 활성 항목에 강조 테두리를 표시할 수 있어요.
highlight-color prop으로 테두리 색상을 바꿀 수 있어요. 기본값은 color prop을 따라가요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Guide",
icon: "i-lucide-book-open",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
defaultOpen: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu highlight highlight-color="primary" orientation="horizontal" :items="items" class="data-[orientation=horizontal]:border-b border-default data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-48" />
</template>
[!NOTE]
이 예시에서는
horizontal방향에서 테두리를 표시하기 위해border-b클래스를 적용했어요. 기본적으로는 적용되지 않아 깨끗한 상태에서 시작할 수 있어요.
[!CAUTION]
vertical방향에서는highlightprop이 활성 하위 항목의 테두리만 강조해요.
Color
color prop으로 NavigationMenu의 색상을 바꿀 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started"
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables"
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
}
]
])
</script>
<template>
<UNavigationMenu color="neutral" :items="items" class="w-full" />
</template>
Variant
variant prop으로 NavigationMenu의 변형을 바꿀 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started"
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables"
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank"
}
]
])
</script>
<template>
<UNavigationMenu color="neutral" variant="link" :highlight="false" :items="items" class="w-full" />
</template>
[!NOTE]
highlightprop은pill변형의 활성 항목 스타일을 바꿔요. 직접 사용해 차이를 확인해 보세요.
Trailing Icon
trailing-icon prop으로 각 항목의 꼬리 Icon을 커스터마이즈할 수 있어요. 기본값은 i-lucide-chevron-down이에요. 이 아이콘은 항목에 하위 항목이 있을 때만 표시돼요.
[!TIP]
항목 객체의
trailingIcon속성을 사용해 특정 항목에 아이콘을 설정할 수도 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
])
</script>
<template>
<UNavigationMenu trailing-icon="i-lucide-arrow-down" :items="items" class="w-full justify-center" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
app.config.ts의ui.icons.chevronDown키 아래에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
vite.config.ts의ui.icons.chevronDown키 아래에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Arrow
arrow prop으로 항목에 하위 항목이 있을 때 NavigationMenu 콘텐츠에 화살표를 표시할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
])
</script>
<template>
<UNavigationMenu arrow :items="items" class="w-full justify-center" />
</template>
[!NOTE]
화살표는 활성 항목을 따라가도록 애니메이션되요.
Content Orientation
content-orientation prop으로 콘텐츠의 방향을 바꿀 수 있어요.
[!WARNING]
이 prop은
orientation이horizontal일 때만 동작해요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
}
]
}
])
</script>
<template>
<UNavigationMenu arrow content-orientation="vertical" :items="items" class="w-full justify-center" />
</template>
Unmount
unmount-on-hide prop으로 콘텐츠가 숨겨질 때 unmount 동작을 제어해요. 기본값은 true예요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[]>([
{
label: "Guide",
icon: "i-lucide-book-open",
to: "/docs/getting-started",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
to: "/docs/composables",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
])
</script>
<template>
<UNavigationMenu :unmount-on-hide="false" :items="items" class="w-full justify-center" />
</template>
[!NOTE]
DOM을 검사하여 각 항목의 콘텐츠가 렌더링되는 것을 확인할 수 있어요.
예시 (Examples)
활성 항목 제어하기 (Control active item)
default-value prop이나 v-model 지시자에 항목의 value를 사용해 활성 항목을 제어할 수 있어요. value를 제공하지 않으면 최상위 항목은 item-${index}, 중첩 항목은 item-${level}-${index}로 기본 설정돼요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[] = [
{
label: 'Guide',
icon: 'i-lucide-book-open',
children: [
{
label: 'Introduction',
description: 'Fully styled and customizable components for Nuxt.',
icon: 'i-lucide-house'
},
{
label: 'Installation',
description: 'Learn how to install and configure Nuxt UI in your application.',
icon: 'i-lucide-cloud-download'
},
{
label: 'Icons',
icon: 'i-lucide-smile',
description: 'You have nothing to do, @nuxt/icon will handle it automatically.'
},
{
label: 'Colors',
icon: 'i-lucide-swatch-book',
description: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
},
{
label: 'Theme',
icon: 'i-lucide-cog',
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
}
]
},
{
label: 'Composables',
icon: 'i-lucide-database',
children: [
{
label: 'defineShortcuts',
icon: 'i-lucide-file-text',
description: 'Define shortcuts for your application.'
},
{
label: 'useOverlay',
icon: 'i-lucide-file-text',
description: 'Display a modal/slideover within your application.'
},
{
label: 'useToast',
icon: 'i-lucide-file-text',
description: 'Display a toast within your application.'
}
]
},
{
label: 'Components',
icon: 'i-lucide-box',
children: [
{
label: 'Link',
icon: 'i-lucide-file-text',
description: 'Use NuxtLink with superpowers.'
},
{
label: 'Modal',
icon: 'i-lucide-file-text',
description: 'Display a modal within your application.'
},
{
label: 'NavigationMenu',
icon: 'i-lucide-file-text',
description: 'Display a list of links.'
},
{
label: 'Pagination',
icon: 'i-lucide-file-text',
description: 'Display a list of pages.'
},
{
label: 'Popover',
icon: 'i-lucide-file-text',
description: 'Display a non-modal dialog that floats around a trigger element.'
},
{
label: 'Progress',
icon: 'i-lucide-file-text',
description: 'Show a horizontal bar to indicate task progression.'
}
]
}
]
const active = ref()
defineShortcuts({
1: () => {
active.value = 'item-0'
},
2: () => {
active.value = 'item-1'
},
3: () => {
active.value = 'item-2'
}
})
</script>
<template>
<UNavigationMenu v-model="active" :items="items" class="w-full justify-center" />
</template>
[!TIP]
v-model이나default-value가 제공될 때 항목을 매칭하는 데 사용할 키를 바꾸려면value-keyprop을 사용해요.
[!NOTE]
이 예시에서는
defineShortcuts를 활용해1,2,3키를 눌러 활성 항목을 전환할 수 있어요.
항목에 툴팁 (With tooltip in items)
방향이 vertical이고 메뉴가 collapsed일 때 tooltip prop을 true로 설정하면 항목 레이블로 그 주위에 Tooltip을 표시할 수 있고, 각 항목의 tooltip 속성으로 기본 툴팁을 덮어쓸 수도 있어요. horizontal 방향에서도 각 항목의 tooltip 속성을 사용해 항목 주위에 Tooltip을 표시할 수 있어요.
[!NOTE]
항목의
tooltip속성은 전역tooltipprop과 관계없이 항상 툴팁을 표시해요.
Tooltip 컴포넌트의 어떤 속성이든 전역 또는 각 항목에 전달할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Links",
type: "label"
},
{
label: "Guide",
icon: "i-lucide-book-open",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank",
tooltip: {
text: "Open on GitHub",
kbds: [
"6k"
]
}
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu tooltip collapsed orientation="vertical" :items="items" />
</template>
항목에 팝오버 (With popover in items)
방향이 vertical이고 메뉴가 collapsed일 때 popover prop을 true로 설정하면 하위 항목이 있는 항목 주위에 Popover를 표시할 수 있고, 각 항목의 popover 속성으로 기본 팝오버를 덮어쓸 수도 있어요.
[!NOTE]
항목의
popover속성은 전역popoverprop과 관계없이 항상 팝오버를 표시해요.
Popover 컴포넌트의 어떤 속성이든 전역 또는 각 항목에 전달할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Links",
type: "label"
},
{
label: "Guide",
icon: "i-lucide-book-open",
children: [
{
label: "Introduction",
description: "Fully styled and customizable components for Nuxt.",
icon: "i-lucide-house"
},
{
label: "Installation",
description: "Learn how to install and configure Nuxt UI in your application.",
icon: "i-lucide-cloud-download"
},
{
label: "Icons",
icon: "i-lucide-smile",
description: "You have nothing to do, @nuxt/icon will handle it automatically."
},
{
label: "Colors",
icon: "i-lucide-swatch-book",
description: "Choose a primary and a neutral color from your Tailwind CSS theme."
},
{
label: "Theme",
icon: "i-lucide-cog",
description: "You can customize components by using the `class` / `ui` props or in your app.config.ts."
}
]
},
{
label: "Composables",
icon: "i-lucide-database",
popover: {
mode: "click"
},
children: [
{
label: "defineShortcuts",
icon: "i-lucide-file-text",
description: "Define shortcuts for your application.",
to: "/docs/composables/define-shortcuts"
},
{
label: "useOverlay",
icon: "i-lucide-file-text",
description: "Display a modal/slideover within your application.",
to: "/docs/composables/use-overlay"
},
{
label: "useToast",
icon: "i-lucide-file-text",
description: "Display a toast within your application.",
to: "/docs/composables/use-toast"
}
]
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
children: [
{
label: "Link",
icon: "i-lucide-file-text",
description: "Use NuxtLink with superpowers.",
to: "/docs/components/link"
},
{
label: "Modal",
icon: "i-lucide-file-text",
description: "Display a modal within your application.",
to: "/docs/components/modal"
},
{
label: "NavigationMenu",
icon: "i-lucide-file-text",
description: "Display a list of links.",
to: "/docs/components/navigation-menu"
},
{
label: "Pagination",
icon: "i-lucide-file-text",
description: "Display a list of pages.",
to: "/docs/components/pagination"
},
{
label: "Popover",
icon: "i-lucide-file-text",
description: "Display a non-modal dialog that floats around a trigger element.",
to: "/docs/components/popover"
},
{
label: "Progress",
icon: "i-lucide-file-text",
description: "Show a horizontal bar to indicate task progression.",
to: "/docs/components/progress"
}
]
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
badge: "6k",
to: "https://github.com/nuxt/ui",
target: "_blank",
tooltip: {
text: "Open on GitHub",
kbds: [
"6k"
]
}
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu popover collapsed orientation="vertical" :items="items" />
</template>
[!TIP] See: #with-content-slot
vertical방향에서#content슬롯을 사용해 팝오버의 콘텐츠를 커스터마이즈할 수 있어요.
항목에 칩 (With chip in items) 4.5+
chip 속성을 사용해 항목의 아이콘 주위에 Chip을 표시할 수 있고, 그 속성을 전달할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = ref<NavigationMenuItem[][]>([
[
{
label: "Guide",
icon: "i-lucide-book-open",
chip: {
color: "error"
}
},
{
label: "Composables",
icon: "i-lucide-database",
chip: {
color: "info",
text: 3
}
},
{
label: "Components",
icon: "i-lucide-box",
to: "/docs/components",
active: true,
chip: true
}
],
[
{
label: "GitHub",
icon: "i-simple-icons-github",
to: "https://github.com/nuxt/ui",
target: "_blank"
},
{
label: "Help",
icon: "i-lucide-circle-help",
disabled: true
}
]
])
</script>
<template>
<UNavigationMenu collapsed orientation="vertical" :items="items" />
</template>
하단 탭 바 (With bottom tab bar)
ui prop을 사용해 NavigationMenu를 YouTube나 Instagram과 유사한, 아이콘과 작은 레이블을 가진 모바일 스타일 하단 탭 바로 변환할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Samples',
icon: 'i-lucide-circle-play'
},
{
label: 'Explore',
icon: 'i-lucide-compass'
},
{
label: 'Library',
icon: 'i-lucide-bookmark'
}
]
</script>
<template>
<UNavigationMenu
:items="items"
:ui="{
root: 'justify-around border-t border-default py-2',
item: 'py-0',
link: 'flex-col gap-1 px-3',
linkLeadingIcon: 'size-5',
linkLabel: 'text-[10px]/3 font-normal'
}"
class="w-full"
/>
</template>
접힌 레이블 (With collapsed labels)
ui prop을 사용해 접힐 때 각 아이콘 아래에 레이블을 표시할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house'
},
{
label: 'Search',
icon: 'i-lucide-search'
},
{
label: 'Users',
icon: 'i-lucide-users',
active: true
},
{
label: 'Settings',
icon: 'i-lucide-cog'
}
]
</script>
<template>
<UNavigationMenu
collapsed
orientation="vertical"
:items="items"
:ui="{
link: 'flex-col gap-1',
linkLabel: 'block text-[10px]/3 text-center'
}"
/>
</template>
[!TIP]
compoundVariants를 사용해app.config.ts에서 전역으로도 할 수 있어요.export default defineAppConfig({ ui: { navigationMenu: { compoundVariants: [{ orientation: 'vertical', collapsed: true, class: { link: 'flex-col', linkLabel: 'block text-[10px]/3 text-center' } }] } } })
커스텀 슬롯 (With custom slot)
slot 속성을 사용해 특정 항목을 커스터마이즈할 수 있어요.
다음 슬롯들을 사용할 수 있어요.
#{{ item.slot }}#{{ item.slot }}-leading#{{ item.slot }}-label#{{ item.slot }}-trailing#{{ item.slot }}-content
<script setup lang="ts">
import type { NavigationMenuItem, DropdownMenuItem } from '@nuxt/ui'
const items = [
{
label: 'Guide',
icon: 'i-lucide-book-open',
to: '/docs/getting-started'
},
{
label: 'Composables',
icon: 'i-lucide-database',
to: '/docs/composables',
class: 'hidden'
},
{
label: 'Components',
icon: 'i-lucide-box',
to: '/docs/components',
class: 'hidden'
},
{
slot: 'more' as const,
as: 'span',
class: 'p-0',
content: {
align: 'start' as const
},
items: [
{
label: 'Composables',
icon: 'i-lucide-database',
to: '/docs/composables'
},
{
label: 'Components',
icon: 'i-lucide-box',
to: '/docs/components'
}
] satisfies DropdownMenuItem[]
},
{
label: 'GitHub',
icon: 'i-simple-icons-github',
to: 'https://github.com/nuxt/ui',
target: '_blank',
slot: 'github' as const
}
] satisfies NavigationMenuItem[]
</script>
<template>
<UNavigationMenu :items="items" class="w-full justify-center">
<template #more="{ item }">
<UDropdownMenu :content="item.content" :items="item.items">
<UButton icon="i-lucide-ellipsis" color="neutral" variant="link" />
</UDropdownMenu>
</template>
<template #github-trailing>
<UBadge label="6k+" color="neutral" variant="subtle" size="sm" />
</template>
</UNavigationMenu>
</template>
[!TIP] See: #slots
#item,#item-leading,#item-label,#item-trailing,#item-content슬롯을 사용해 모든 항목을 커스터마이즈할 수도 있어요.
꼬리 슬롯 (With trailing slot)
#item-trailing 슬롯 또는 slot 속성(#{{ item.slot }}-trailing)을 사용해 Notion이나 Linear처럼 호버 시 나타나는 DropdownMenu을 추가할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem, DropdownMenuItem } from '@nuxt/ui'
const items: NavigationMenuItem[][] = [
[
{
label: 'Personal',
type: 'label',
slot: 'personal-label' as const
},
{
label: 'Design System',
icon: 'i-lucide-folder',
active: true
},
{
label: 'Travel',
icon: 'i-lucide-folder'
}
],
[
{
label: 'Teams',
type: 'label',
slot: 'teams-label' as const
},
{
label: 'Engineering',
icon: 'i-lucide-folder'
},
{
label: 'Marketing',
icon: 'i-lucide-folder'
}
]
]
const dropdownItems: DropdownMenuItem[][] = [
[
{ label: 'View Project', icon: 'i-lucide-folder-open' },
{ label: 'Share Project', icon: 'i-lucide-share' }
],
[
{ label: 'Delete Project', icon: 'i-lucide-trash', color: 'error' }
]
]
</script>
<template>
<UNavigationMenu
orientation="vertical"
:items="items"
:ui="{ link: 'overflow-hidden has-data-[state=open]:before:bg-elevated/50' }"
class="w-48"
>
<template #personal-label-trailing>
<UButton icon="i-lucide-plus" color="neutral" variant="ghost" size="xs" />
</template>
<template #teams-label-trailing>
<UButton icon="i-lucide-plus" color="neutral" variant="ghost" size="xs" />
</template>
<template #item-trailing>
<div class="flex -mr-1.5 -my-0.5 translate-x-full group-hover:translate-x-0 has-data-[state=open]:translate-x-0 transition-transform">
<UDropdownMenu
:items="dropdownItems"
:content="{ align: 'start' }"
:modal="false"
size="xs"
>
<UButton
as="div"
icon="i-lucide-ellipsis"
color="neutral"
variant="ghost"
size="xs"
class="text-muted hover:text-highlighted hover:bg-accented/50 data-[state=open]:bg-accented/50 mr-1.5"
/>
</UDropdownMenu>
</div>
</template>
</UNavigationMenu>
</template>
콘텐츠 슬롯 (With content slot)
#item-content 슬롯 또는 slot 속성(#{{ item.slot }}-content)을 사용해 특정 항목의 콘텐츠를 커스터마이즈할 수 있어요.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const items = [
{
label: 'Docs',
icon: 'i-lucide-book-open',
slot: 'docs' as const,
children: [
{
label: 'Icons',
description: 'You have nothing to do, @nuxt/icon will handle it automatically.'
},
{
label: 'Colors',
description: 'Choose a primary and a neutral color from your Tailwind CSS theme.'
},
{
label: 'Theme',
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
}
]
},
{
label: 'Components',
icon: 'i-lucide-box',
slot: 'components' as const,
children: [
{
label: 'Link',
description: 'Use NuxtLink with superpowers.'
},
{
label: 'Modal',
description: 'Display a modal within your application.'
},
{
label: 'NavigationMenu',
description: 'Display a list of links.'
},
{
label: 'Pagination',
description: 'Display a list of pages.'
},
{
label: 'Popover',
description: 'Display a non-modal dialog that floats around a trigger element.'
},
{
label: 'Progress',
description: 'Show a horizontal bar to indicate task progression.'
}
]
},
{
label: 'GitHub',
icon: 'i-simple-icons-github'
}
] satisfies NavigationMenuItem[]
</script>
<template>
<UNavigationMenu
:items="items"
:ui="{
viewport: 'sm:w-(--reka-navigation-menu-viewport-width)',
content: 'sm:w-auto',
childList: 'sm:w-96',
childLinkDescription: 'text-balance line-clamp-2'
}"
class="w-full justify-center"
>
<template #docs-content="{ item }">
<ul class="grid gap-2 p-4 lg:w-[500px] lg:grid-cols-[minmax(0,.75fr)_minmax(0,1fr)]">
<li class="row-span-3">
<Placeholder class="size-full min-h-48" />
</li>
<li v-for="child in item.children" :key="child.label">
<ULink class="text-sm text-left rounded-md p-3 transition-colors hover:bg-elevated/50">
<p class="font-medium text-highlighted">
{{ child.label }}
</p>
<p class="text-muted line-clamp-2">
{{ child.description }}
</p>
</ULink>
</li>
</ul>
</template>
</UNavigationMenu>
</template>
[!NOTE]
이 예시에서는 동적 너비를 위해
viewport에sm:w-(--reka-navigation-menu-viewport-width)클래스를 추가해요. 이 경우 콘텐츠의 첫 번째 자식에 너비를 설정해야 해요.
API
Props
/**
* Props for the NavigationMenu component
*/
interface NavigationMenuProps {
/**
* The element or component this component should render as.
* @default 'div'
*/
as?: any;
/**
* Determines whether a "single" or "multiple" items can be selected at a time.
*
* Only works when `orientation` is `vertical`.
* @default 'multiple'
*/
type?: K | undefined;
/**
* The controlled value of the active item(s).
* - In horizontal orientation: always `string`
* - In vertical orientation with `type="single"`: `string`
* - In vertical orientation with `type="multiple"`: `string[]`
*
* Use this when you need to control the state of the items. Can be binded with `v-model`
*/
modelValue?: NavigationMenuModelValue<K, O> | undefined;
/**
* The default active value of the item(s).
* - In horizontal orientation: always `string`
* - In vertical orientation with `type="single"`: `string`
* - In vertical orientation with `type="multiple"`: `string[]`
*
* Use when you do not need to control the state of the item(s).
*/
defaultValue?: NavigationMenuModelValue<K, O> | undefined;
/**
* The icon displayed to open the menu.
* @default appConfig.ui.icons.chevronDown
*/
trailingIcon?: any;
/**
* The icon displayed when the item is an external link.
* Set to `false` to hide the external icon.
* @default true
*/
externalIcon?: any;
items?: T | undefined;
/**
* @default 'primary'
*/
color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* @default 'pill'
*/
variant?: "pill" | "link" | undefined;
/**
* The orientation of the menu.
* @default 'horizontal'
*/
orientation?: O | undefined;
/**
* Collapse the navigation menu to only show icons.
* Only works when `orientation` is `vertical`.
* @default false
*/
collapsed?: boolean | undefined;
/**
* Display a tooltip on the items with the label of the item.
* Only works when `orientation` is `vertical` and `collapsed` is `true`.
* `{ delayDuration: 0, content: { side: 'right' } }`{lang="ts-type"}
* @default false
*/
tooltip?: boolean | TooltipProps | undefined;
/**
* Display a popover on the items when the menu is collapsed with the children list.
* `{ mode: 'hover', content: { side: 'right', align: 'start', alignOffset: 2 } }`{lang="ts-type"}
* @default false
*/
popover?: boolean | PopoverProps<PopoverMode> | undefined;
/**
* Display a line next to the active item.
*/
highlight?: boolean | undefined;
/**
* @default 'primary'
*/
highlightColor?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* The content of the menu.
*/
content?: Omit<NavigationMenuContentProps, "as" | "asChild" | "forceMount"> & Partial<EmitsToProps<DismissableLayerEmits>> | undefined;
/**
* The orientation of the content.
* Only works when `orientation` is `horizontal`.
* @default 'horizontal'
*/
contentOrientation?: "horizontal" | "vertical" | undefined;
/**
* Display an arrow alongside the menu.
* @default false
*/
arrow?: boolean | undefined;
/**
* The key used to get the value from the item.
* @default 'value'
*/
valueKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
/**
* The key used to get the label from the item.
* @default 'label'
*/
labelKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
ui?: { root?: SlotClass; list?: SlotClass; label?: SlotClass; item?: SlotClass; link?: SlotClass; linkLeadingIcon?: SlotClass; linkLeadingAvatar?: SlotClass; linkLeadingAvatarSize?: SlotClass; linkLeadingChipSize?: SlotClass; linkTrailing?: SlotClass; linkTrailingBadge?: SlotClass; linkTrailingBadgeSize?: SlotClass; linkTrailingIcon?: SlotClass; linkLabel?: SlotClass; linkLabelExternalIcon?: SlotClass; childList?: SlotClass; childLabel?: SlotClass; childItem?: SlotClass; childLink?: SlotClass; childLinkWrapper?: SlotClass; childLinkIcon?: SlotClass; childLinkLabel?: SlotClass; childLinkLabelExternalIcon?: SlotClass; childLinkDescription?: SlotClass; separator?: SlotClass; viewportWrapper?: SlotClass; viewport?: SlotClass; content?: SlotClass; indicator?: SlotClass; arrow?: SlotClass; } | undefined;
/**
* The duration from when the pointer enters the trigger until the tooltip gets opened.
* @default 0
*/
delayDuration?: number | undefined;
/**
* If `true`, menu cannot be open by click on trigger
* @default false
*/
disableClickTrigger?: boolean | undefined;
/**
* If `true`, menu cannot be open by hover on trigger
* @default false
*/
disableHoverTrigger?: boolean | undefined;
/**
* How much time a user has to enter another trigger without incurring a delay again.
* @default 300
*/
skipDelayDuration?: number | undefined;
/**
* If `true`, menu will not close during pointer leave event
* @default false
*/
disablePointerLeaveClose?: boolean | undefined;
/**
* When `true`, the element will be unmounted on closed state.
* @default true
*/
unmountOnHide?: boolean | undefined;
/**
* When `true`, prevents the user from interacting with the accordion and all its items
* @default false
*/
disabled?: boolean | undefined;
/**
* When type is "single", allows closing content when clicking trigger for an open item.
* When type is "multiple", this prop has no effect.
* @default true
*/
collapsible?: boolean | undefined;
}
Slots
/**
* Slots for the NavigationMenu component
*/
interface NavigationMenuSlots {
item(): any;
item-leading(): any;
item-label(): any;
item-trailing(): any;
item-content(): any;
list-leading(): any;
list-trailing(): any;
}
Emits
/**
* Emitted events for the NavigationMenu component
*/
interface NavigationMenuEmits {
update:modelValue: (payload: [value: NavigationMenuModelValue<K, O> | undefined]) => void;
}
테마 (Theme)
export default defineAppConfig({
ui: {
navigationMenu: {
slots: {
root: 'relative flex gap-1.5 [&>div]:min-w-0',
list: 'isolate min-w-0',
label: 'w-full flex items-center gap-1.5 font-semibold text-xs/5 text-highlighted px-2.5 py-1.5',
item: 'min-w-0',
link: 'group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none focus-visible:before:outline-3',
linkLeadingIcon: 'shrink-0 size-5',
linkLeadingAvatar: 'shrink-0',
linkLeadingAvatarSize: '2xs',
linkLeadingChipSize: 'sm',
linkTrailing: 'group ms-auto inline-flex gap-1.5 items-center',
linkTrailingBadge: 'shrink-0',
linkTrailingBadgeSize: 'sm',
linkTrailingIcon: 'size-5 transform shrink-0 group-data-[state=open]:rotate-180 transition-transform duration-200 ease-out motion-reduce:transition-none',
linkLabel: 'truncate',
linkLabelExternalIcon: 'inline-block size-3 align-top text-dimmed',
childList: 'isolate',
childLabel: 'text-xs text-highlighted',
childItem: '',
childLink: 'group relative size-full flex items-start text-start text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none focus-visible:before:outline-3',
childLinkWrapper: 'min-w-0',
childLinkIcon: 'size-5 shrink-0',
childLinkLabel: 'truncate',
childLinkLabelExternalIcon: 'inline-block size-3 align-top text-dimmed',
childLinkDescription: 'text-muted',
separator: 'px-2 h-px bg-border',
viewportWrapper: 'absolute top-full start-0 flex w-full',
viewport: 'relative overflow-hidden bg-default shadow-lg rounded-md ring ring-default h-(--reka-navigation-menu-viewport-height) w-full transition-[width,height,left,right] duration-200 ease-out motion-reduce:transition-none origin-[top_center] data-[state=open]:animate-[scale-in_100ms_var(--ease-out)] data-[state=closed]:animate-[scale-out_100ms_var(--ease-out)] z-1',
content: '',
indicator: 'absolute left-0 data-[state=visible]:animate-[fade-in_100ms_var(--ease-out)] data-[state=hidden]:animate-[fade-out_100ms_var(--ease-out)] data-[state=hidden]:opacity-0 bottom-0 z-2 w-(--reka-navigation-menu-indicator-size) translate-x-(--reka-navigation-menu-indicator-position) flex h-2.5 items-end justify-center overflow-hidden transition-[translate,width] duration-200 ease-out motion-reduce:transition-none',
arrow: 'relative top-[50%] size-2.5 rotate-45 border border-default bg-default z-1 rounded-xs'
},
variants: {
color: {
primary: {
link: 'before:outline-primary/25',
childLink: 'before:outline-primary/25'
},
secondary: {
link: 'before:outline-secondary/25',
childLink: 'before:outline-secondary/25'
},
success: {
link: 'before:outline-success/25',
childLink: 'before:outline-success/25'
},
info: {
link: 'before:outline-info/25',
childLink: 'before:outline-info/25'
},
warning: {
link: 'before:outline-warning/25',
childLink: 'before:outline-warning/25'
},
error: {
link: 'before:outline-error/25',
childLink: 'before:outline-error/25'
},
neutral: {
link: 'before:outline-inverted/25',
childLink: 'before:outline-inverted/25'
}
},
highlightColor: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
pill: '',
link: ''
},
orientation: {
horizontal: {
root: 'items-center justify-between',
list: 'flex items-center',
item: 'py-2',
link: 'px-2.5 py-1.5 before:inset-x-px before:inset-y-0',
childList: 'grid p-2',
childLink: 'px-3 py-2 gap-2 before:inset-x-px before:inset-y-0',
childLinkLabel: 'font-medium',
content: 'absolute top-0 start-0 w-full max-h-[70vh] overflow-y-auto'
},
vertical: {
root: 'flex-col',
link: 'flex-row px-2.5 py-1.5 before:inset-y-px before:inset-x-0',
childLabel: 'px-1.5 py-0.5',
childLink: 'p-1.5 gap-1.5 before:inset-y-px before:inset-x-0'
}
},
contentOrientation: {
horizontal: {
viewportWrapper: 'justify-center',
content: 'data-[motion=from-start]:animate-[enter-from-left_200ms_var(--ease-out)] data-[motion=from-end]:animate-[enter-from-right_200ms_var(--ease-out)] data-[motion=to-start]:animate-[exit-to-left_200ms_var(--ease-out)] data-[motion=to-end]:animate-[exit-to-right_200ms_var(--ease-out)]'
},
vertical: {
viewport: 'sm:w-(--reka-navigation-menu-viewport-width) left-(--reka-navigation-menu-viewport-left) rtl:left-auto rtl:right-[calc(100%-var(--reka-navigation-menu-viewport-left)-var(--reka-navigation-menu-viewport-width))]'
}
},
active: {
true: {
childLink: 'before:bg-elevated text-highlighted',
childLinkIcon: 'text-default'
},
false: {
link: 'text-muted',
linkLeadingIcon: 'text-dimmed',
childLink: [
'hover:before:bg-elevated/50 text-default hover:text-highlighted',
'transition-colors before:transition-colors'
],
childLinkIcon: [
'text-dimmed group-hover:text-default',
'transition-colors'
]
}
},
disabled: {
true: {
link: 'cursor-not-allowed opacity-75'
}
},
highlight: {
true: ''
},
level: {
true: ''
},
collapsed: {
true: ''
}
},
compoundVariants: [
{
orientation: 'horizontal',
contentOrientation: 'horizontal',
class: {
childList: 'grid-cols-2 gap-2'
}
},
{
orientation: 'horizontal',
contentOrientation: 'vertical',
class: {
childList: 'gap-1',
content: 'w-60'
}
},
{
orientation: 'vertical',
collapsed: false,
class: {
childList: 'ms-5 border-s border-default',
childItem: 'ps-1.5 -ms-px',
content: 'data-[state=open]:animate-[collapsible-down_200ms_var(--ease-out)] data-[state=closed]:animate-[collapsible-up_200ms_var(--ease-out)] data-[state=closed]:overflow-hidden'
}
},
{
orientation: 'vertical',
collapsed: true,
class: {
link: 'px-1.5',
linkLabel: 'hidden',
linkTrailing: 'hidden',
content: 'shadow-sm rounded-sm min-h-6 p-1'
}
},
{
orientation: 'horizontal',
highlight: true,
class: {
link: [
'after:absolute after:-bottom-2 after:inset-x-2.5 after:block after:h-px after:rounded-full',
'after:transition-colors'
]
}
},
{
orientation: 'vertical',
highlight: true,
level: true,
class: {
link: [
'after:absolute after:-start-1.5 after:inset-y-0.5 after:block after:w-px after:rounded-full',
'after:transition-colors'
]
}
},
{
disabled: false,
active: false,
variant: 'pill',
class: {
link: [
'hover:text-highlighted hover:before:bg-elevated/50',
'transition-colors before:transition-colors'
],
linkLeadingIcon: [
'group-hover:text-default',
'transition-colors'
]
}
},
{
disabled: false,
active: false,
variant: 'pill',
orientation: 'horizontal',
class: {
link: 'data-[state=open]:text-highlighted',
linkLeadingIcon: 'group-data-[state=open]:text-default'
}
},
{
disabled: false,
variant: 'pill',
highlight: true,
orientation: 'horizontal',
class: {
link: 'data-[state=open]:before:bg-elevated/50'
}
},
{
disabled: false,
variant: 'pill',
highlight: false,
active: false,
orientation: 'horizontal',
class: {
link: 'data-[state=open]:before:bg-elevated/50'
}
},
{
color: 'primary',
variant: 'pill',
active: true,
class: {
link: 'text-primary',
linkLeadingIcon: 'text-primary group-data-[state=open]:text-primary'
}
},
{
color: 'secondary',
variant: 'pill',
active: true,
class: {
link: 'text-secondary',
linkLeadingIcon: 'text-secondary group-data-[state=open]:text-secondary'
}
},
{
color: 'success',
variant: 'pill',
active: true,
class: {
link: 'text-success',
linkLeadingIcon: 'text-success group-data-[state=open]:text-success'
}
},
{
color: 'info',
variant: 'pill',
active: true,
class: {
link: 'text-info',
linkLeadingIcon: 'text-info group-data-[state=open]:text-info'
}
},
{
color: 'warning',
variant: 'pill',
active: true,
class: {
link: 'text-warning',
linkLeadingIcon: 'text-warning group-data-[state=open]:text-warning'
}
},
{
color: 'error',
variant: 'pill',
active: true,
class: {
link: 'text-error',
linkLeadingIcon: 'text-error group-data-[state=open]:text-error'
}
},
{
color: 'neutral',
variant: 'pill',
active: true,
class: {
link: 'text-highlighted',
linkLeadingIcon: 'text-highlighted group-data-[state=open]:text-highlighted'
}
},
{
variant: 'pill',
active: true,
highlight: false,
class: {
link: 'before:bg-elevated'
}
},
{
variant: 'pill',
active: true,
highlight: true,
disabled: false,
class: {
link: [
'hover:before:bg-elevated/50',
'before:transition-colors'
]
}
},
{
disabled: false,
active: false,
variant: 'link',
class: {
link: [
'hover:text-highlighted',
'transition-colors'
],
linkLeadingIcon: [
'group-hover:text-default',
'transition-colors'
]
}
},
{
disabled: false,
active: false,
variant: 'link',
orientation: 'horizontal',
class: {
link: 'data-[state=open]:text-highlighted',
linkLeadingIcon: 'group-data-[state=open]:text-default'
}
},
{
color: 'primary',
variant: 'link',
active: true,
class: {
link: 'text-primary',
linkLeadingIcon: 'text-primary group-data-[state=open]:text-primary'
}
},
{
color: 'secondary',
variant: 'link',
active: true,
class: {
link: 'text-secondary',
linkLeadingIcon: 'text-secondary group-data-[state=open]:text-secondary'
}
},
{
color: 'success',
variant: 'link',
active: true,
class: {
link: 'text-success',
linkLeadingIcon: 'text-success group-data-[state=open]:text-success'
}
},
{
color: 'info',
variant: 'link',
active: true,
class: {
link: 'text-info',
linkLeadingIcon: 'text-info group-data-[state=open]:text-info'
}
},
{
color: 'warning',
variant: 'link',
active: true,
class: {
link: 'text-warning',
linkLeadingIcon: 'text-warning group-data-[state=open]:text-warning'
}
},
{
color: 'error',
variant: 'link',
active: true,
class: {
link: 'text-error',
linkLeadingIcon: 'text-error group-data-[state=open]:text-error'
}
},
{
color: 'neutral',
variant: 'link',
active: true,
class: {
link: 'text-highlighted',
linkLeadingIcon: 'text-highlighted group-data-[state=open]:text-highlighted'
}
},
{
highlightColor: 'primary',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-primary'
}
},
{
highlightColor: 'secondary',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-secondary'
}
},
{
highlightColor: 'success',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-success'
}
},
{
highlightColor: 'info',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-info'
}
},
{
highlightColor: 'warning',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-warning'
}
},
{
highlightColor: 'error',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-error'
}
},
{
highlightColor: 'neutral',
highlight: true,
level: true,
active: true,
class: {
link: 'after:bg-inverted'
}
}
],
defaultVariants: {
color: 'primary',
highlightColor: 'primary',
variant: 'pill'
}
}
}
})