Skip to main content

Menu

The ty-menu is an advanced custom menu component designed with extensibility and customization in mind. It supports flexible positioning relative to a target element, and works seamlessly with ty-menu-item components to provide a complete menu experience. The ty-menu component also supports standard menu behaviors while offering additional features like custom events.

The ty-menu-item is a robust custom component designed to represent individual menu items within a ty-menu. It supports standard menu item behaviors while offering additional features like custom icons and custom events.

Usage

To use ty-menu and ty-menu-item, include it in your HTML code and wrap your ty-menu-item elements within it. You can also specify a target-id and placement attribute on the ty-menu for customizing the positioning.

Live Editor
<div>
  <ty-button variant="icon" id="target-id">
    <span class="material-icons">settings</span>
  </ty-button>

  <ty-menu target-id="target-id" placement="bottom-end">
    <ty-menu-item value="3">Menu item 3</ty-menu-item>
    <ty-menu-item value="4">Menu item 4</ty-menu-item>
  </ty-menu>
</div>
Result
Loading...

API

Properties

ty-menu

The ty-menu component accepts the following properties:

NameDescriptionTypeDefault
target-idThe id of the element the menu is positioned relative tostring''
placementThe placement of the menu relative to the target elementstring'bottom'

ty-menu-item

The ty-menu-item component accepts the following properties:

NameDescriptionTypeDefault
valueThe value of the menu itemstring''
sizeSize'sm', 'md''md'
cornerBorder radius when hover'none', 'xs', 'sm''none'
activeSet active statebooleanfalse

Events

ty-menu

NameDescriptionDetail
ty-changeFires when a menu item is selected{ value: string }

ty-menu-item

NameDescriptionDetail
ty-clickFires when the menu item is clicked{ value: string }

The ty-change event on ty-menu provides a convenient way to listen for selections within the menu, whereas the ty-click event on ty-menu-item provides a way to listen for clicks on individual menu items.