Skip to content

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.

<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>

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
Customcolor
<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

<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>
ParameterDescriptionTypeOptionsDefault
modeModestringhorizontal / verticalvertical
collapseWhether to horizontally collapse the menu (only available when mode is vertical)booleanfalse
background-colorMenu background color (hex format only)string#ffffff
text-colorMenu text color (hex format only)stringrgba(0,0,0,.65)
active-text-colorText color of the currently active menu item (hex format only)string#1089ff
default-activeIndex of the currently active menu itemstring
default-openedsArray of indices of currently opened sub-menusArray
unique-openedWhether to keep only one sub-menu expanded at a timebooleanfalse
menu-triggerTrigger mode for opening sub-menus (only effective when mode is horizontal)stringhover / clickhover
routerWhether to use vue-router mode. Enabling this mode will use the index as the path for route navigation when activating a menu itembooleanfalse
Method NameDescriptionParameter
openExpand the specified sub-menuindex: index of the sub-menu to open
closeCollapse the specified sub-menuindex: index of the sub-menu to collapse
Event NameDescriptionCallback Parameters
selectMenu activation callbackindex: index of the selected menu item, indexPath: index path of the selected menu item
openSub-menu expand callbackindex: index of the opened sub-menu, indexPath: index path of the opened sub-menu
closeSub-menu collapse callbackindex: index of the collapsed sub-menu, indexPath: index path of the collapsed sub-menu
ParameterDescriptionTypeOptionsDefault
indexUnique identifierstring/nullnull
popper-classCustom class name for the opened menustring
show-timeoutDelay before expanding a sub-menunumber300
hide-timeoutDelay before collapsing a sub-menunumber300
disabledDisabledbooleanfalse
popper-append-to-bodyWhether to append the opened menu to the body element. If the menu positioning has issues, try modifying this propertybooleanFirst-level sub-menu: true / Non-first-level sub-menu: false
ParameterDescriptionTypeOptionsDefault
indexUnique identifierstring
routeVue Router path objectObject
disabledDisabledbooleanfalse
ParameterDescriptionTypeOptionsDefault
titleGroup titlestring