Skip to content

Menu

The Menu component displays a hierarchical list for any type of vertical navigation, where the items can be expanded or collapsed. The component implements the W3C ARIA APG Tree View Pattern.

Examples

Base

Instead of using the HTML button tag, the HTML tag can be customised using the tag prop.

Options

Instead of using the <o-menu-item> component directly inside the default slot, an options prop can be defined, which can be used to define the options programmatically. It accepts several different formats of values:

  • An array of primitives ['A', 'B', 'C']
  • An object literal with key-value pairs { a: 'A', b: 'B', c: 'C' }
  • An array of objects with label and value properties
  • Grouped options by adding additional options to the option object.

Note

The options prop works the same as the Select input component options prop.

A simple menu, for any type of vertical navigation.

html
<o-menu></o-menu>

Props

Prop nameDescriptionTypeValuesDefault
accordionIf sub menu items are collapsibleboolean-true
disabledMenu will be disabledboolean-false
iconIcon to be shownstring-
iconPackIcon pack to usestringmdi, fa, fas and any other custom icon pack
From config:
menu: {
  iconPack: undefined
}
iconSizeIcon sizestringsmall, medium, large
From config:
menu: {
  iconSize: undefined
}
labelMenu labelstring-
labelIdHTML element Id of the label elementstring-useId()
menuIdHTML element Id of the ol list elementstring-useId()
v-modelThe selected item value, use v-model to make it two-way bindingunknown-
optionsMenu items, unnecessary when default slot is usedOptionsPropWithGroups<unknown>-
overrideOverride existing theme classes completelyboolean-
roleRole attribute to be passed to the list container for better accessibility.
Use menu only in situations where your dropdown is related to a navigation menu.
"menu" | "tree"menu, tree
From config:
menu: {
  role: "tree"
}

Events

Event namePropertiesDescription
update:model-valuevalue T - updated modelValue propmodelValue prop two-way binding

Slots

NameDescriptionBindings
labelOverride icon and labelfocused T - the focused item value

selected T - the selected item value
defaultPlace menu items herefocused T - the focused item value

selected T - the selected item value

A menu list item.

html
<o-menu-item></o-menu-item>

Props

Prop nameDescriptionTypeValuesDefault
activeThe active state of the menu item, use v-model:active to make it two-way bindingboolean-false
animationTransition name to apply on menu liststring-
From config:
menu: {
  animation: "slide"
}
disabledMenu item will be disabledboolean-false
expandedMenu item will be expandedboolean-false
hiddenDefine whether the item is visible or notboolean-false
iconIcon to be shownstring-
iconPackIcon pack to usestringmdi, fa, fas and any other custom icon pack
From config:
menu: {
  iconPack: undefined
}
iconSizeIcon sizestringsmall, medium, large
From config:
menu: {
  iconSize: undefined
}
labelMenu item labelstring-
optionsSubmenu items, unnecessary when default slot is usedOptionsProp<unknown>-
overrideOverride existing theme classes completelyboolean-
submenuIdHTML element Id of the sub menu ol list elementstring-useId()
tagMenu item tag nameDynamicComponent-
From config:
menu: {
  itemTag: "button"
}
valueItem value (it will be used as v-model of wrapper component) - default is an uuidunknown-

Events

Event namePropertiesDescription
update:activevalue boolean - updated active propactive prop two-way binding
clickvalue string | number | object - value prop data
event event - Native Event
onclick event

Slots

NameDescriptionBindings
labelOverride labelexpanded boolean - item expanded state
active boolean - item active state
defaultPlace menu items here

Class Inspector

Classes applied to the element:
Class propDescriptionPropsSuffixes
rootClassClass of the root element.
listClassClass of the menu list element.
labelClassClass of the menu label element.
itemClassClass of the menu item root element.
itemActiveClassClass of the menu item root element when active.
itemFocusedClassClass of the menu item root element when focused.
itemDisabledClassClass of the menu item root element when disabled.disabled
itemButtonClassClass of the menu button element.
itemButtonActiveClassClass of the menu button element when active.
itemButtonFocusedClassClass of the menu button element when focused.
itemButtonDisabledClassClass of the menu button element when disabled.disabled
itemButtonIconClassClass of the menu button element with icon.icon
itemSubmenuClassClass of the menu item submenu element.

Sass variables

Current theme ➜ Oruga

SASS VariableDefault
$menu-item-colorvar(--#{$prefix}grey-dark)
$menu-item-background-colortransparent
$menu-item-hover-colorvar(--#{$prefix}black)
$menu-item-hover-background-colorvar(--#{$prefix}grey-light)
$menu-item-active-colorvar(--#{$prefix}primary-invert)
$menu-item-active-background-colorvar(--#{$prefix}primary)
$menu-item-disabled-colorvar(--#{$prefix}grey-light)
$menu-list-border-left1px solid var(--#{$prefix}primary)
$menu-list-border-radiusvar(--#{$prefix}base-border-radius)
$menu-list-line-height1.25em
$menu-item-padding0.5em 0.75em
$menu-nested-list-margin0.75em 1.25em
$menu-nested-list-padding-left0.75em
$menu-label-color$grey
$menu-label-font-size0.75em
$menu-label-spacing1em
$menu-icon-spacer0.5rem

See ➜ 📄 Full scss file

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

SASS VariableDefault
$menu-label-bgtransparent
$menu-label-colorvar(--#{$prefix}body-color)
$menu-label-font-size0.75em
$menu-list-line-height1.25em
$menu-item-padding0.5em 0.75em
$menu-item-bgtransparent
$menu-item-colorvar(--#{$prefix}body-color)
$menu-item-active-bgvar(--#{$prefix}primary)
$menu-item-active-colorvar(--#{$prefix}white)
$menu-item-disabled-bgtransparent
$menu-item-disabled-colorvar(--#{$prefix}secondary)
$menu-item-border-radiusvar(--#{$prefix}border-radius)
$menu-item-hover-bgvar(--#{$prefix}tertiary-bg)
$menu-item-hover-colorvar(--#{$prefix}body-color)
$menu-icon-spacer0.5rem
$menu-submenu-border-left1px solid #445e00
$menu-submenu-padding0 0.75em
$menu-submenu-margin0.75em 1.25em

See ➜ 📄 Full scss file

Released under the MIT License.