Docs

Context Menu

Context Menu is a component that you can attach to any component to display a context menu.

The menu appears by default on right-click, or it can appear on left-click. On a touch device, a long press opens the context menu. Below is a default example:

<ContextMenu items={items}>
  <Grid items={people} allRowsVisible>
    <GridColumn path="firstName" />
    <GridColumn path="lastName" />
    <GridColumn path="email" />
    <GridColumn header="Phone number" path="address.phone" />
  </Grid>
</ContextMenu>

Dividers

You can use dividers to separate and group related content. Use dividers sparingly to avoid creating unnecessary visual clutter.

Checkable Menu Items

Checkable Menu Items can be used to toggle a setting on and off.

Hierarchical Menu

Context Menu, like Menu Bar, supports multi-level sub-menus. You can use a hierarchical menu to organize a large set of options and group related items.

Custom Items

You can customize the items to include more than a single line of text.

Disabled Menu Items

You can disable menu items to show that they are unavailable.

Left-Click

You can use left-click to open Context Menu in situations where left-click has no other function. An example of such a situation would be a Grid without selection support.

Best Practices

Context Menu is used to offer shortcuts to the user. You shouldn’t use it as the only or primary means to complete a task. The primary way should be accessible elsewhere in the UI.

Context Menu vs. Menu Bar

You should use Context Menu when there is no dedicated button for opening an overlay menu, such as right-clicking a grid row. When there is a dedicated element or component, such as an overflow menu, use Menu Bar.

Icons

Use icons when applicable to help improve recognition. It’s recommended to use commonly recognized icons to avoid confusion. Use icons consistently throughout a list of options.

Labelling

Suffix a menu item with ellipses (i.e., "…") when the associated action won’t be executed, but instead reveals some UI. An example of this is when an item leads to a dialog, for completing the action.

Component Usage Recommendation

Menu Bar

Component for displaying a horizontal menu with multi-level sub-menus.

Important
You can find more information in the corresponding article on vaadin.com.