UIMenu
UIMenu
A menu component for navigation and command execution.
<template> <UIMenu v-model:selectedKeys="selectedKeys" v-model:openKeys="openKeys" mode="inline" :items="menuItems" @select="handleSelect" > <template #icon-dashboard> <DashboardIcon /> </template> <template #icon-settings> <SettingsIcon /> </template> </UIMenu></template>
<script setup lang="ts">interface MenuItem { key: string label: string icon?: string children?: MenuItem[] disabled?: boolean}
const selectedKeys = ref(['dashboard'])const openKeys = ref(['sub1'])
const menuItems: MenuItem[] = [ { key: 'dashboard', label: 'Dashboard', icon: 'dashboard' }, { key: 'sub1', label: 'Settings', icon: 'settings', children: [ { key: 'profile', label: 'Profile Settings' }, { key: 'security', label: 'Security Settings' } ] }]
const handleSelect = ({ key, keyPath }: { key: string; keyPath: string[] }) => { console.log('Selected:', key, keyPath)}</script>Props
items(array): Menu items configurationmode(‘vertical’ | ‘horizontal’ | ‘inline’): Menu display modetheme(‘light’ | ‘dark’): Menu themeselectedKeys(string[]): Currently selected menu itemsopenKeys(string[]): Currently opened submenu keyscollapsed(boolean): Collapse inline menumultiple(boolean): Allow multiple selectionsinlineIndent(number): Indent of inline menu itemsdisabled(boolean): Disable entire menuexpandIcon(VNode): Custom expand icontriggerSubMenuAction(‘hover’ | ‘click’): How to trigger submenuselectable(boolean): Whether menu items are selectable
Events
update:selectedKeys: Emitted when selection changesupdate:openKeys: Emitted when open keys changeselect: Emitted when menu item is selecteddeselect: Emitted when menu item is deselectedclick: Emitted when menu item is clickedopenChange: Emitted when submenu open/close state changes
Slots
default: Custom menu contentexpandIcon: Custom expand iconicon-[iconName]: Custom icon for menu itemssuffix-[key]: Custom suffix for menu items
MenuItem Props
key(string): Unique identifierlabel(string): Menu item texticon(string): Icon namedisabled(boolean): Disable itemdanger(boolean): Danger styletitle(string): Tooltip titlechildren(array): Submenu items