Menu
A navigation menu for websites.
Top Bar
By default, the menu is in vertical mode. Use the mode prop to switch to horizontal mode. Use the submenu component for nested sub-menus. Menu also provides background-color, text-color, and active-text-color to set the menu's background color, text color, and active item text color respectively.
- Processing Center
- My Workspace
- Message Center
- Documentation
- Processing Center
- My Workspace
- Message Center
- Documentation
<template>
<div>
<b-menu
:default-active="activeIndex"
class="b-menu-demo"
mode="horizontal"
style="padding-left: 55px"
@select="handleSelect"
>
<b-menu-item index="1">Processing Center</b-menu-item>
<b-submenu index="2">
<template #title>My Workspace</template>
<b-menu-item index="2-1">Option 1</b-menu-item>
<b-menu-item index="2-2">Option 2</b-menu-item>
<b-menu-item index="2-3">Option 3</b-menu-item>
<b-submenu index="2-4">
<template #title>Option 4</template>
<b-menu-item index="2-4-1">Option 1</b-menu-item>
<b-menu-item index="2-4-2">Option 2</b-menu-item>
<b-menu-item index="2-4-3">Option 3</b-menu-item>
</b-submenu>
</b-submenu>
<b-menu-item index="3" disabled>Message Center</b-menu-item>
<b-menu-item index="4">
<a href="https://wangbin3162.github.io/bin-ui-design/" target="_blank">Documentation</a>
</b-menu-item>
</b-menu>
<b-divider />
<b-menu
:default-active="activeIndex2"
class="b-menu-demo"
mode="horizontal"
background-color="#001529"
text-color="#fff"
active-text-color="#ffd04b"
style="padding-left: 55px"
@select="handleSelect"
>
<b-menu-item index="1">Processing Center</b-menu-item>
<b-submenu index="2">
<template #title>My Workspace</template>
<b-menu-item index="2-1">Option 1</b-menu-item>
<b-menu-item index="2-2">Option 2</b-menu-item>
<b-menu-item index="2-3">Option 3</b-menu-item>
<b-submenu index="2-4">
<template #title>Option 4</template>
<b-menu-item index="2-4-1">Option 1</b-menu-item>
<b-menu-item index="2-4-2">Option 2</b-menu-item>
<b-menu-item index="2-4-3">Option 3</b-menu-item>
</b-submenu>
</b-submenu>
<b-menu-item index="3" disabled>Message Center</b-menu-item>
<b-menu-item index="4">
<a href="https://wangbin3162.github.io/bin-ui-design/" target="_blank">Documentation</a>
</b-menu-item>
</b-menu>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const activeIndex = ref('1')
const activeIndex2 = ref('1')
function handleSelect(key, keyPath) {
console.log(key, keyPath)
}
</script>Sidebar
Vertical menu with nested sub-menus. Use the b-menu-item-group component to group menu items. The group name can be set directly via the title property or through a named slot.
Default Colors
- Nav One
- Group One
- Option 1
- Option 2
- Grouped2
- Option 3
- Option 4
- Option 1
- Nav Two
- Nav Three
- Nav Four
Customcolor
- Nav One
- Group One
- Option 1
- Option 2
- Grouped2
- Option 3
- Option 4
- Option 1
- Nav Two
- Nav Three
- Nav Four
<template>
<b-row class="tac">
<b-col :span="12">
<h5 style="margin-bottom: 10px">Default Colors</h5>
<b-menu
default-active="2"
class="b-menu-vertical-demo border"
@open="handleOpen"
@close="handleClose"
>
<b-submenu index="1">
<template #title>
<b-icon name="location-fill"></b-icon>
<span>Nav One</span>
</template>
<b-menu-item-group>
<template #title>Group One</template>
<b-menu-item index="1-1">Option 1</b-menu-item>
<b-menu-item index="1-2">Option 2</b-menu-item>
</b-menu-item-group>
<b-menu-item-group title="Grouped2">
<b-menu-item index="1-3">Option 3</b-menu-item>
</b-menu-item-group>
<b-submenu index="1-4">
<template #title>Option 4</template>
<b-menu-item index="1-4-1">Option 1</b-menu-item>
</b-submenu>
</b-submenu>
<b-menu-item index="2">
<b-icon name="appstore-fill"></b-icon>
<template #title>Nav Two</template>
</b-menu-item>
<b-menu-item index="3" disabled>
<b-icon name="file-text"></b-icon>
<template #title>Nav Three</template>
</b-menu-item>
<b-menu-item index="4">
<b-icon name="setting-fill"></b-icon>
<template #title>Nav Four</template>
</b-menu-item>
</b-menu>
</b-col>
<b-col :span="12">
<h5 style="margin-bottom: 10px">Customcolor</h5>
<b-menu
:unique-opened="true"
default-active="2"
class="b-menu-vertical-demo"
background-color="#495662"
text-color="#fff"
active-text-color="#ffd04b"
@open="handleOpen"
@close="handleClose"
>
<b-submenu index="1">
<template #title>
<b-icon name="location-fill"></b-icon>
<span>Nav One</span>
</template>
<b-menu-item-group>
<template #title>Group One</template>
<b-menu-item index="1-1">Option 1</b-menu-item>
<b-menu-item index="1-2">Option 2</b-menu-item>
</b-menu-item-group>
<b-menu-item-group title="Grouped2">
<b-menu-item index="1-3">Option 3</b-menu-item>
</b-menu-item-group>
<b-submenu index="1-4">
<template #title>Option 4</template>
<b-menu-item index="1-4-1">Option 1</b-menu-item>
</b-submenu>
</b-submenu>
<b-menu-item index="2">
<b-icon name="appstore-fill"></b-icon>
<template #title>Nav Two</template>
</b-menu-item>
<b-menu-item index="3" disabled>
<b-icon name="file-text"></b-icon>
<template #title>Nav Three</template>
</b-menu-item>
<b-menu-item index="4">
<b-icon name="setting-fill"></b-icon>
<template #title>Nav Four</template>
</b-menu-item>
</b-menu>
</b-col>
</b-row>
</template>
<script setup lang="ts">
function handleOpen(key, keyPath) {
console.log(key, keyPath)
}
function handleClose(key, keyPath) {
console.log(key, keyPath)
}
</script>
<style scoped>
.b-menu-vertical-demo {
width: 240px;
border-right: 1px solid #f0f0f0;
}
</style>collapse
- Nav One
- Group One
- Option 1
- Option 2
- Grouped2
- Option 3
- Option 4
- Option 1
- Nav Two
- Nav Three
- Nav Four
<template>
<div>
<b-button-group v-model="isCollapse" style="margin-bottom: 20px">
<b-button :type="isCollapse ? 'default' : 'primary'" @click="isCollapse = false">
Expand
</b-button>
<b-button :type="isCollapse ? 'primary' : 'default'" @click="isCollapse = true">
Collapse
</b-button>
</b-button-group>
<b-menu
style="width: 240px"
default-active="1-4-1"
:collapse="isCollapse"
background-color="#232324"
text-color="#fff"
active-text-color="#ffd04b"
class="b-menu-vertical-demo border"
@open="handleOpen"
@close="handleClose"
>
<b-submenu index="1">
<template #title>
<b-icon name="location-fill"></b-icon>
<span>Nav One</span>
</template>
<b-menu-item-group>
<template #title>Group One</template>
<b-menu-item index="1-1">Option 1</b-menu-item>
<b-menu-item index="1-2">Option 2</b-menu-item>
</b-menu-item-group>
<b-menu-item-group title="Grouped2">
<b-menu-item index="1-3">Option 3</b-menu-item>
</b-menu-item-group>
<b-submenu index="1-4">
<template #title>Option 4</template>
<b-menu-item index="1-4-1">Option 1</b-menu-item>
</b-submenu>
</b-submenu>
<b-menu-item index="2">
<b-icon name="appstore-fill"></b-icon>
<template #title>Nav Two</template>
</b-menu-item>
<b-menu-item index="3" disabled>
<b-icon name="file-text"></b-icon>
<template #title>Nav Three</template>
</b-menu-item>
<b-menu-item index="4">
<b-icon name="setting-fill"></b-icon>
<template #title>Nav Four</template>
</b-menu-item>
</b-menu>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const isCollapse = ref(false)
function handleOpen(key, keyPath) {
console.log(key, keyPath)
}
function handleClose(key, keyPath) {
console.log(key, keyPath)
}
</script>
<style scoped>
.b-menu-vertical-demo {
width: 240px;
border-right: 1px solid #f0f0f0;
}
</style>Menu Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| mode | Mode | string | horizontal / vertical | vertical |
| collapse | Whether to horizontally collapse the menu (only available when mode is vertical) | boolean | — | false |
| background-color | Menu background color (hex format only) | string | — | #ffffff |
| text-color | Menu text color (hex format only) | string | — | rgba(0,0,0,.65) |
| active-text-color | Text color of the currently active menu item (hex format only) | string | — | #1089ff |
| default-active | Index of the currently active menu item | string | — | — |
| default-openeds | Array of indices of currently opened sub-menus | Array | — | — |
| unique-opened | Whether to keep only one sub-menu expanded at a time | boolean | — | false |
| menu-trigger | Trigger mode for opening sub-menus (only effective when mode is horizontal) | string | hover / click | hover |
| router | Whether to use vue-router mode. Enabling this mode will use the index as the path for route navigation when activating a menu item | boolean | — | false |
Menu Methods
| Method Name | Description | Parameter |
|---|---|---|
| open | Expand the specified sub-menu | index: index of the sub-menu to open |
| close | Collapse the specified sub-menu | index: index of the sub-menu to collapse |
Menu Events
| Event Name | Description | Callback Parameters |
|---|---|---|
| select | Menu activation callback | index: index of the selected menu item, indexPath: index path of the selected menu item |
| open | Sub-menu expand callback | index: index of the opened sub-menu, indexPath: index path of the opened sub-menu |
| close | Sub-menu collapse callback | index: index of the collapsed sub-menu, indexPath: index path of the collapsed sub-menu |
SubMenu Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| index | Unique identifier | string/null | — | null |
| popper-class | Custom class name for the opened menu | string | — | — |
| show-timeout | Delay before expanding a sub-menu | number | — | 300 |
| hide-timeout | Delay before collapsing a sub-menu | number | — | 300 |
| disabled | Disabled | boolean | — | false |
| popper-append-to-body | Whether to append the opened menu to the body element. If the menu positioning has issues, try modifying this property | boolean | — | First-level sub-menu: true / Non-first-level sub-menu: false |
Menu-Item Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| index | Unique identifier | string | — | — |
| route | Vue Router path object | Object | — | — |
| disabled | Disabled | boolean | — | false |
Menu-Group Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| title | Group title | string | — | — |