Menu #
The VaMenu
component is used to display structured information under the menu button.
Examples #
Basic usage #
Required to have a anchor. Component will automatically listen for clicks, keyboard navigation and open/close menu. Here's an example using options
prop:
Slot usage #
You can also use slot and VaMenuItem component to achieve better flexibility.
Context menu #
One of the most common use cases for VaMenu
component is context menu. You can use cursor
prop to enable context menu mode. In this mode menu will be opened on right click.
useMenu #
You can use useMenu
hook to show menu programmatically. useMenu
will listen for right click to show menu.
- User 1
- User 2
- User 3
- User 4
Icon #
You can use icon
and rightIcon
properties in options or left-icon
and right-icon
slots in VaMenuItem
component.
Group #
You can use group
property in options or VaMenuGroup
component.
With divider #
You can use VaDivider
component in pair with VaMenuItem
components.
Props #
Name | Description | Types | Default |
---|---|---|---|
anchor | Anchor element. Dropdown will be opened when clicked on anchor. Can be |
| - |
anchorSelector | Anchor CSS selector instead of passing slot |
|
|
ariaLabel | Sets the |
|
|
autoPlacement | If dropdown doesn't fit viewport, it will be placed automatically to fit viewport |
|
|
closeOnAnchorClick | Dropdown will be closed when clicked on anchor |
|
|
closeOnClickOutside | Dropdown will be closed when clicked outside dropdown content and anchor |
|
|
closeOnContentClick | Dropdown will be closed when clicked inside dropdown content |
|
|
closeOnFocusOutside | Dropdown will be closed when focus is outside dropdown content and anchor |
|
|
contentClass |
|
| |
cursor | Dropdown will be rendered relative to cursor position |
|
|
disabled | Applies |
| - |
disabledBy | Specify the key in the object to be used as item |
|
|
groupBy | When |
|
|
hoverOutTimeout | Time in |
|
|
hoverOverTimeout | Time in |
|
|
innerAnchorSelector | Anchor CSS selector inside passed slot |
|
|
isContentHoverable | If true, dropdown content will be hoverable |
|
|
keepAnchorWidth | If true, dropdown content will have exact same width as anchor |
|
|
keyboardNavigation | Enables keyboard navigation for the component. |
|
|
modelValue | The value of the |
|
|
offset | Dropdown content will be moved by main and cross axis according to current |
|
|
options | Available options that the user can select from |
|
|
placement | Dropdown content will be placed on |
|
|
preset | Named preset combination of component props. |
| - |
readonly | Doesn't look disabled, but acts like one. Mostly useful for wrapper components. |
| - |
role | The role attribute of the dropdown |
|
|
stateful | Add possibility to work with component without setting |
|
|
stickToEdges | Dropdown will not be rendered outside of viewport. It will be moved in opposite direction. |
|
|
target | Dropdown content parent. Dropdown content will be attached to |
| - |
teleport | Element where content will be rendered |
| - |
textBy | When |
|
|
trackBy | When |
|
|
trigger | Action that will triggered when open and close dropdown. |
|
|
valueBy | When |
|
|
verticalScrollOnOverflow | If true, dropdown content will adjust its height when the content is larger than available space |
|
|
Events #
Name | Description |
---|---|
anchorClick | The event is triggered when anchor is clicked |
anchorDblclick | The event is triggered when anchor is double clicked |
anchorRightClick | The event is triggered when anchor is right clicked |
clickOutside | The event is triggered when clicked outside dropdown content and anchor |
close | The event is triggered when dropdown is closed |
contentClick | The event is triggered when clicked inside dropdown content |
focusOutside | The event is triggered when focus is outside dropdown content and anchor |
open | The event is triggered when dropdown is opened |
selected | Emitted when an option is selected. Returns the selected option value as first argument and the selected option as second argument |
update:modelValue | The event is triggered when the component needs to change the model. Is also used by |