Menu
A versatile menu for navigation.
When To Use
Navigation is an important part of any website, as a good navigation setup allows users to move around the site quickly and efficiently. Ant Design offers top and side navigation options. Top navigation provides all the categories and functions available in the application. Side navigation provides multi-level navigation for additional content.
Examples
Top Navigation
vue
<template>
<a-menu v-model:selectedKeys="current" mode="horizontal">
<a-menu-item key="mail">
<template #icon>
<MailOutlined />
</template>
Navigation One
</a-menu-item>
<a-menu-item key="app" disabled>
<template #icon>
<AppstoreOutlined />
</template>
Navigation Two
</a-menu-item>
<a-sub-menu key="SubMenu">
<template #title>
<span>
<SettingOutlined />
<span>Navigation Three - Submenu</span>
</span>
</template>
<a-menu-item-group title="Item 1">
<a-menu-item key="setting:1">Option 1</a-menu-item>
<a-menu-item key="setting:2">Option 2</a-menu-item>
</a-menu-item-group>
<a-menu-item-group title="Item 2">
<a-menu-item key="setting:3">Option 3</a-menu-item>
<a-menu-item key="setting:4">Option 4</a-menu-item>
</a-menu-item-group>
</a-sub-menu>
<a-menu-item key="alipay">
<a href="https://antdv.com" target="_blank" rel="noopener noreferrer">
Navigation Four - Link
</a>
</a-menu-item>
</a-menu>
</template>
<script setup>
import { ref } from 'vue'
import { MailOutlined, AppstoreOutlined, SettingOutlined } from '@ant-design/icons-vue'
const current = ref(['mail'])
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Inline Menu
vue
<template>
<a-menu
v-model:selectedKeys="selectedKeys"
v-model:openKeys="openKeys"
mode="inline"
theme="dark"
:inline-collapsed="collapsed"
:style="{ width: '256px' }"
>
<a-menu-item key="1">
<template #icon>
<PieChartOutlined />
</template>
<span>Option 1</span>
</a-menu-item>
<a-menu-item key="2">
<template #icon>
<DesktopOutlined />
</template>
<span>Option 2</span>
</a-menu-item>
<a-menu-item key="3">
<template #icon>
<InboxOutlined />
</template>
<span>Option 3</span>
</a-menu-item>
<a-sub-menu key="sub1">
<template #icon>
<MailOutlined />
</template>
<template #title>Navigation One</template>
<a-menu-item key="5">Option 5</a-menu-item>
<a-menu-item key="6">Option 6</a-menu-item>
<a-menu-item key="7">Option 7</a-menu-item>
<a-menu-item key="8">Option 8</a-menu-item>
</a-sub-menu>
<a-sub-menu key="sub2">
<template #icon>
<AppstoreOutlined />
</template>
<template #title>Navigation Two</template>
<a-menu-item key="9">Option 9</a-menu-item>
<a-menu-item key="10">Option 10</a-menu-item>
<a-sub-menu key="sub3" title="Submenu">
<a-menu-item key="11">Option 11</a-menu-item>
<a-menu-item key="12">Option 12</a-menu-item>
</a-sub-menu>
</a-sub-menu>
</a-menu>
</template>
<script setup>
import { ref } from 'vue'
import {
PieChartOutlined,
DesktopOutlined,
InboxOutlined,
MailOutlined,
AppstoreOutlined
} from '@ant-design/icons-vue'
const selectedKeys = ref(['1'])
const openKeys = ref(['sub1'])
const collapsed = ref(false)
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Collapsed inline menu
vue
<template>
<div style="width: 256px">
<a-button type="primary" @click="toggleCollapsed" style="margin-bottom: 16px">
<MenuUnfoldOutlined v-if="collapsed" />
<MenuFoldOutlined v-else />
</a-button>
<a-menu
v-model:selectedKeys="selectedKeys"
v-model:openKeys="openKeys"
mode="inline"
theme="dark"
:inline-collapsed="collapsed"
>
<a-menu-item key="1">
<template #icon>
<PieChartOutlined />
</template>
<span>Option 1</span>
</a-menu-item>
<a-menu-item key="2">
<template #icon>
<DesktopOutlined />
</template>
<span>Option 2</span>
</a-menu-item>
<a-menu-item key="3">
<template #icon>
<InboxOutlined />
</template>
<span>Option 3</span>
</a-menu-item>
<a-sub-menu key="sub1">
<template #icon>
<MailOutlined />
</template>
<template #title>Navigation One</template>
<a-menu-item key="5">Option 5</a-menu-item>
<a-menu-item key="6">Option 6</a-menu-item>
<a-menu-item key="7">Option 7</a-menu-item>
<a-menu-item key="8">Option 8</a-menu-item>
</a-sub-menu>
<a-sub-menu key="sub2">
<template #icon>
<AppstoreOutlined />
</template>
<template #title>Navigation Two</template>
<a-menu-item key="9">Option 9</a-menu-item>
<a-menu-item key="10">Option 10</a-menu-item>
<a-sub-menu key="sub3" title="Submenu">
<a-menu-item key="11">Option 11</a-menu-item>
<a-menu-item key="12">Option 12</a-menu-item>
</a-sub-menu>
</a-sub-menu>
</a-menu>
</div>
</template>
<script setup>
import { ref } from 'vue'
import {
PieChartOutlined,
DesktopOutlined,
InboxOutlined,
MailOutlined,
AppstoreOutlined,
MenuUnfoldOutlined,
MenuFoldOutlined
} from '@ant-design/icons-vue'
const selectedKeys = ref(['1'])
const openKeys = ref(['sub1'])
const collapsed = ref(false)
const toggleCollapsed = () => {
collapsed.value = !collapsed.value
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
API
Menu
Property | Description | Type | Default | Version |
---|---|---|---|---|
defaultOpenKeys | Array with the keys of default opened sub menus | string[] | - | |
defaultSelectedKeys | Array with the keys of default selected menu items | string[] | - | |
expandIcon | custom expand icon of submenu | slot | - | |
forceSubMenuRender | Render submenu into DOM before it becomes visible | boolean | false | |
inlineCollapsed | Specifies the collapsed status when menu is inline mode | boolean | - | |
inlineIndent | Indent (in pixels) of inline menu items on each level | number | 24 | |
mode | Type of menu | vertical | horizontal | inline | vertical | |
multiple | Allows selection of multiple items | boolean | false | |
openKeys(v-model) | Array with the keys of currently opened sub-menus | string[] | - | |
overflowedIndicator | Customized the ellipsis icon when menu is collapsed horizontally | slot | <EllipsisOutlined /> | |
selectable | Allows selecting menu items | boolean | true | |
selectedKeys(v-model) | Array with the keys of currently selected menu items | string[] | - | |
subMenuCloseDelay | Delay time to hide submenu when mouse leaves (in seconds) | number | 0.1 | |
subMenuOpenDelay | Delay time to show submenu when mouse enters, (in seconds) | number | 0 | |
theme | Color theme of the menu | light | dark | light | |
triggerSubMenuAction | Which action can trigger submenu open/close | hover | click | hover |
Menu Events
Events Name | Description | Arguments | Version |
---|---|---|---|
click | Callback executed when a menu item is clicked | function({ item, key, keyPath, domEvent }) | |
deselect | Callback executed when a menu item is deselected, only supported for multiple mode | function({ item, key, selectedKeys }) | |
openChange | Callback executed when sub-menus are opened or closed | function(openKeys: string[]) | |
select | Callback executed when a menu item is selected | function({ item, key, selectedKeys }) |
Menu.Item
Property | Description | Type | Default | Version |
---|---|---|---|---|
disabled | Whether menu item is disabled | boolean | false | |
key | Unique ID of the menu item | string | - | |
title | Set display title for collapsed item | string | - |
Menu.SubMenu
Property | Description | Type | Default | Version |
---|---|---|---|---|
disabled | Whether sub-menu is disabled | boolean | false | |
key | Unique ID of the sub-menu | string | - | |
popupClassName | Sub-menu class name, not working when mode="inline" | string | - | |
popupOffset | Sub-menu offset, not working when mode="inline" | [number, number] | - | |
title | Title of sub menu | string | slot | - |
Menu.ItemGroup
Property | Description | Type | Default | Version |
---|---|---|---|---|
title | Title of the group | string | slot | - |
Menu.Divider
Divider line in between menu items, only used in vertical popup Menu or Dropdown Menu.