Skip to content

Menu item

<tpg-menu-item></tpg-menu-item>

Menus are a continuous group of text or icons with text. They appear when users interact with a icon buttons, buttons, and text fields (Combo box).

Menus display a list of choices on a temporary surface, and allow users to make a selection from multiple options. They appear in front of all other permanent UI elements.

Examples

Basic

With icons

Combine leading, secondaryLeading, trailing and secondaryTrailing as you wish.

Secondary label

Use the secondaryLabel to add a secondary label.

Disabled

Use the disabled prop to make the item disabled.

Icon only

Use the iconOnly combined with a leadingIcon to create a icon only menu-item.

With badge

There are two ways to render a badge within the Menu Item. Slotting one in using slot="badge", and setting the badge-value attribute.

Only one badge can be rendered at once, and the slotted badge takes precedence over the one set using the badge-value attribute, meaning badge-value will be ignored should both be provided.

The badge-value renders a predesigned badge, whereas the slot allows you to customize the badge yourself.

Tables

Properties

Attribute Property Description Type Default Value
label label The label for the component. string ''
value value The value of the component. string ''
badge-value badgeValue A simple string value used to render a predesigned badge. Ignored if a custom badge is provided via the `badge` slot. string ''
secondary-label secondaryLabel The secondary label for the component. string ''
type type The type of the component, either 'default' or 'error'. 'default' | 'error' 'default'
leading-icon-template leadingIconTemplate The template for the leading icon. IconConstant | '' ''
override-leading-icon-template-color overrideLeadingIconTemplateColor The color to override the leadingIconTemplate string ''
secondary-leading-icon-template secondaryLeadingIconTemplate The template for the secondary leading icon. IconConstant | '' ''
trailing-icon-template trailingIconTemplate The template for the trailing icon. IconConstant | '' ''
secondary-trailing-icon-template secondaryTrailingIconTemplate The template for the secondary trailing icon. IconConstant | '' ''
disabled disabled Whether the component is disabled. boolean false
selected selected Whether the component is selected. boolean false

Events

Event name Reactjs attribute Description
tpg-select ontpg-select Emitted when the item is selected, containing the value identifier of this item.

Functions

Name Description Arguments
No functions found.

Slots

Name Description
badge The badge to be shown in the menu item. Note: If a badge is provided via the badge slot, it will take precedence over the badgeValue property. This means that if both are provided, only the slotted badge will be rendered, and the badgeValue will be ignored.
content Alternative rendering for menu item.

CSS Parts

Attribute Description
No CSS parts found.

Sandbox