Skip to content

MenuButton ​

The MenuButton component is a ToggleButton that, when toggled on, displays a Menu with actions.

NameValue
Props
disabled
Slots
default
View
Reading direction

Overview ​

When to use MenuButton ​

Use the MenuButton component when the space is limited and you need to provide users with a set of related actions or options within a single button.

Avoid using MenuButton when there are only one or two actions to display. In that case, consider using separate buttons instead. Additionally, do not use MenuButton if the actions are essential and require immediate visibility without additional interaction.

The items within the Menu are meant to be actions. For a menu of selectable options, use Select.

About MenuButton ​

MenuButton includes the following elements.

ToggleButton ​

A single button to display the Menu. It can include an icon, a text label, or both.

A list of related actions. The Menu can be placed in a variety of positions relative to the button.

  • Make MenuItems more easily recognizable by including clear and relevant icons.
  • Don't use thumbnails within MenuItems, as they could make the Menu excessively large.

MenuItems can represent two types of actions:

  1. Standard actions
    Neutral actions such as "Edit" or "Share".
  2. Destructive actions
    Actions with potentially negative or irreversible impact, such as "Delete".

Examples ​

Basic usage ​

The ToggleButton that displays the Menu can be customized with text, an Icon, or both.

Developer notes

MenuButton has two required props: selected and menuItems. The selected prop needs to be bound with v-model.

Icon-only ​

To add an icon, insert the Icon component in the slot content. Refer to the Icon component and the overview of icons to learn more about using icons.

  • When using an icon-only ToggleButton, add an `aria-label` to provide a label to users of assistive technology.

Refer to the MenuItem component to learn about all features available for menuItems.

Triggering actions ​

When the user selects a MenuItem, it can trigger an immediate action instead of (or in addition to) storing their choice as a persistent selection.

  • If an action is destructive, label it as such to inform users of its consequences.
  • Don't include more than one destructive action within the menu.

In this example, selecting a MenuItem causes a message to temporarily display.

Developer notes

In this example, the component listens for @update:selected events from the MenuButton component, handles the selection change with the onSelect method, displays a temporary message using the Message component, and resets the selection after a few seconds.

Other features ​

The MenuButton component has an internal ToggleButton and Menu. You can use the following features from those components in the MenuButton component:

Technical implementation ​

Vue usage ​

Props ​

Prop nameDescriptionTypeDefault
selected(required)Value of the current selection.

Must be bound with v-model:selected.
string|number|null
menuItems(required)Menu items and/or menu group definitions.

Menu groups and individual menu items will be output in the order they appear here.
(MenuButtonItemData|MenuGroupData)[]
menuConfigConfiguration for various menu features. All properties default to false.

See the MenuConfig type.
MenuConfig{}
disabledWhether the dropdown is disabled.booleanfalse
footerInteractive footer item.

This is a special menu item which is pinned to the bottom of the menu. When scrolling is enabled within the menu, the footer item will always be visible at the bottom of the menu. When scrolling is not enabled, the footer item will simply appear as the last menu item.

The footer item is selectable, like other menu items.
MenuItemDatanull

Events ​

Event namePropertiesDescription
update:selectedselected string|number - The new selected valueWhen the selected value changes.

Slots ​

NameDescriptionBindings
defaultMenuButton content
menu-itemDisplay of an individual item in the menumenu-item MenuItemData - The current menu item

Keyboard navigation ​

KeyFunction
EnterIf the focus is placed on the button, it opens and closes the menu. If the focus is placed in any of the options within the displayed menu, it activates that option.
SpaceIf the focus is placed on the button, it opens and closes the menu.
Down arrow / Up arrowIf the menu is displayed, it navigates through menu options.
EscIt closes the menu when it is open.
HomeOptionally, it moves the focus to the first option. Optionally, in a single-select listbox, selection may also move with focus. Supporting this key is strongly recommended for lists with more than five options.
EndOptionally, it moves the focus to the last option. Optionally, in a single-select listbox, selection may also move with focus. Supporting this key is strongly recommended for lists with more than five options.