On This Page
A menu which shows up when the user clicks, right-clicks or long-presses a wrapped component.
- Fluent
- Declarative
ContextMenu.builder()
.menu(List.of(
RouteLink.builder()
.label("Page 1")
.build(),
RouteLink.builder()
.label("Page 2")
.build()
))
.wrapped(new Text("I am a wrapped element. Just right click me :)"))
.build(),
TBD
Available properties
This is the list of available properties for a context menu:
| Property | Description | Notes |
|---|---|---|
| id | id for this component | |
| cssClasses | list of css classes | content of the css attribute |
| style | inline style attributes | content of the style attribute |
| menu | list of menu options, as Actionables | |
| wrapped | the wrapped component | any component |
| activateOnLeftClick | to show up the context menu on left click | true/false |
And above is the list of classes implementing the Actionable interface, and their properties.
Common properties for all Actionables
These properties are common to all the menu options
| Property | Description | Notes |
|---|---|---|
| label | text to show. Only if no component is supplied | |
| selected | if this options must appear as checked | |
| component | any component to be displayed instead of label | |
| className | any css class name | |
| disabled | if this option must appear as disabled | |
| disabledOnClick | if this option must be disabled on click | |
| itemData | any object. It will travel back to the backend, if this option is selected |
RouteLink
Use it for taking the user to a concrete route
| Property | Description | Notes |
|---|---|---|
| route | route to navigate to | |
| target | any of Top, Parent |
MenuSeparator
The divider has no properties. Just draws an horizontal line.
Menu
| Property | Description | Notes |
|---|---|---|
| submenu | a list of Actionables (the menu options) |
ContentLink
| Property | Description | Notes |
|---|---|---|
| componentSupplier | a component supplier |
You can see a full explanation of those properties at https://vaadin.com/docs/latest/components/context-menu