Skip to content

Menu

<tpg-menu></tpg-menu>

Basic usage

Menu by itself does not do anything fancy. It’s a floating container with absolute positioning and some simple keydown & mouseover navigation. The isOpen property needs to be manually toggled in order to show/hide the menu based on click events.

The menu can be traversed by mouse-hovering over submenus / menu items, or by using keyboard arrows.

Examples

Apply label to the nested menu with label attribute.

Anchoring the menu

Assigning a HTMLElement to the Menu’s anchor variable will automatically anchor the menu to that element. It positions itself automatically depending on available space, either below or above the anchor element.

You will still have to manually handle opening/closing of the menu.

Keyboard navigation works as normal here, but you will manually need to give the menu focus. The quickest way of doing this is this: menuChildren[0]?.focus()

Tables

Properties

Attribute Property Description Type Default Value
label label The label for the menu. Only applicable on nested menus. string ''
is-open isOpen Determines if the menu is open. boolean false

Events

Event name Reactjs attribute Description
tpg-select ontpg-select Propagated event that fires from `tpg-menu-item`, containing the value identifier of the selected item.

Functions

Name Description Arguments
No functions found.

Slots

Name Description
The items that are to be slotted into the menu. See examples for 'supported' items.

CSS Parts

Attribute Description
No CSS parts found.

Sandbox