Vivid API

Menu Item

An option to appear inside a Menu.

Usage

import { registerMenu, registerMenuItem } from '@vonage/vivid-api';
registerMenu('your-prefix');
registerMenuItem('your-prefix');

Slots

Meta Slot

Use the meta slot to add an element (like a badge or an additional icon).

Using this slot sets the icon, checkbox or radio to be trailing.

Trailing Meta Slot

Use the trailing-meta slot to add an element (like a badge or an additional icon) to the end of Menu Item.

Assign a Menu to the submenu slot to create a submenu.

When the Menu opens or .focus() is called, focus moves to the first Menu Item by default. If there is a child with the autofocus attribute, it will be focused instead.

CSS Variables

Line Clamp

Line clamp by default is set to one line.

This can be changed by setting a css-variable to a fixed number of lines or auto

  • --text-primary-line-clamp for the primary text.
  • --text-secondary-line-clamp for the secondary text.

Presentational

If the Menu Item is not a direct descendant of a Menu, it will automatically become presentational. That means it used only for visual purposes and no longer semantically or functionally act as a Menu Item.

You must wrap it in an element with role="menuitem" to provide the menu item functionality.

Previously you needed to specify role="presentation" in this case. This is no longer necessary as the component will handle it automatically.

Anchored Menu Item

To create a Menu Item that is anchored to a URL do the following:

  • Wrap the vwc-menu-item in an anchor tag.
  • Set the role attribute to menuitem on the anchor tag.

If you are using a framework, just wrap the menu item in any routing component/directive as done with the anchor tag.

API Reference

Properties

PropertyTypeDefaultDescription
checkedAppearance'normal' | 'tick-only'Controls the appearance of the check indicator.
checkTrailingbooleanSets the check element to appear at the end of the Menu Item
checked
(modelValue)
booleanSets the checked state
connotation'accent' | 'cta'Sets the connotation that appears when checked
controlType'checkbox' | 'radio'Whether the menu item should behave as a checkbox or radio button.
disabledbooleanSets the disabled state
expandedbooleanSets the expanded state
textstringText content
textSecondarystringGive more context to the text
PropertyTypeDefaultDescription
check-appearance'normal' | 'tick-only'Controls the appearance of the check indicator.
check-trailingbooleanSets the check element to appear at the end of the Menu Item
checkedbooleanSets the checked state
connotation'accent' | 'cta'Sets the connotation that appears when checked
control-type'checkbox' | 'radio'Whether the menu item should behave as a checkbox or radio button.
disabledbooleanSets the disabled state
expandedbooleanSets the expanded state
textstringText content
text-secondarystringGive more context to the text

Slots

NameDescription
metaAssign nodes to the `meta` slot to set a badge or an additional icon.
submenuAssign a Menu to the `submenu` slot to add a submenu.
trailing-metaAssign nodes to the `meta` slot to set a badge or an additional icon.
NameDescription
metaAssign nodes to the `meta` slot to set a badge or an additional icon.
submenuAssign a Menu to the `submenu` slot to add a submenu.
trailing-metaAssign nodes to the `meta` slot to set a badge or an additional icon.

Events

NameTypeDescription
changeCustomEvent<undefined>Fired when the item is triggered. Does not fire when a submenu is collapsed or expanded.
expanded-changeCustomEvent<HTMLElement>Fired when the expanded state changes.
NameTypeDescription
changeCustomEvent<undefined>Fired when the item is triggered. Does not fire when a submenu is collapsed or expanded.
expanded-changeCustomEvent<HTMLElement>Fired when the expanded state changes.