Skip to main content

MenuItem

shadow

MenuItem is a child of the Menu. element and represents a navigation item within it. It can display a submenu with additional navigation items and also allows icons to be displayed. For examples of using MenuItem, go to the Menu element documentation page.

When to use

Use wje-menu-item when users need to understand location, move between views, or traverse hierarchy.

When not to use

Do not combine multiple competing navigation patterns for the same user flow.

Accessibility

Ensure visible active/selected states, predictable tab order, and clear control naming.

Best Practices

  • Keep URL state and UI navigation state synchronized.
  • Use consistent labels across menu, breadcrumbs, and tabs.
  • Add context for deep structures (breadcrumbs, headings, icon cues).

Attributes and Properties

No properties available for this component.

Events

NameDescription
wje-menu-item:clickEmitted when the component is clicked.

Methods

collapseItem

DescriptionCreates a tooltip for the MenuItem when it is collapsed.
Signature(native: HTMLElement) => HTMLElement

showSubmenu

DescriptionShows the submenu of the MenuItem.
Signature() => void

hideSubmenu

DescriptionHides the submenu of the MenuItem.
Signature() => void
DescriptionToggles the active state of the submenu element. If the submenu is not active, it sets the "active" attribute. If the submenu is already active, it removes the "active" attribute.
Signature(e: Event) => void

deactivateSubmenu

DescriptionDeactivates the submenu by removing the "active" attribute.
Signature() => void

activateSubmenu

DescriptionActivates the submenu of the menu item.
Signature() => void

getTextFromElement

DescriptionExtracts and returns the concatenated text content from all text nodes within the specified element.
Signature(element: HTMLElement) => string

CSS Shadow Parts

NameDescription
nativeThe native part of the menu item.
submenuThe submenu part of the menu item.

CSS Custom Properties

NameDescription
--wje-menu-item-colorSets the text color of a menu item. Accepts any valid CSS color value.
--wje-menu-item-backgroundDefines the background color of a menu item. Default is transparent. Accepts any valid CSS color value.
--wje-menu-item-color-hoverSpecifies the text color of a menu item when hovered. Accepts any valid CSS color value.
--wje-menu-item-background-hoverSets the background color of a menu item when hovered. Accepts any valid CSS color value.
--wje-menu-item-color-focusDefines the text color of a menu item when focused. Accepts any valid CSS color value.
--wje-menu-item-background-focusSpecifies the background color of a menu item when focused. Accepts any valid CSS color value.
--wje-menu-item-color-activeSets the text color of a menu item when active. Accepts any valid CSS color value.
--wje-menu-item-background-activeSpecifies the background color of a menu item when active. Accepts any valid CSS color value.
--wje-menu-item-padding-topSpecifies the top padding inside a menu item. Accepts any valid CSS length value (e.g., px, rem).
--wje-menu-item-padding-bottomSpecifies the bottom padding inside a menu item. Accepts any valid CSS length value (e.g., px, rem).
--wje-menu-item-line-heightSets the line height for the text within a menu item. Accepts any valid CSS length value.
--wje-menu-submenu-offsetDetermines the horizontal offset of a submenu relative to its parent. Accepts any valid CSS length value.
--wje-menu-item-icon-visibilityControls the visibility of the icon in a menu item. Accepts visible, hidden, or collapse.
--wje-menu-item-safe-triangle-cursor-xSpecifies the x-coordinate of the cursor for the safe triangle area. Used for managing hover or focus transitions between menu items and submenus.
--wje-menu-item-safe-triangle-cursor-ySpecifies the y-coordinate of the cursor for the safe triangle area.
--wje-menu-item-safe-triangle-submenu-start-xDefines the x-coordinate where the submenu's safe triangle starts. Helps prevent accidental submenu closing when navigating.
--wje-menu-item-safe-triangle-submenu-start-yDefines the y-coordinate where the submenu's safe triangle starts.
--wje-menu-item-safe-triangle-submenu-end-xSpecifies the x-coordinate where the submenu's safe triangle ends.
--wje-menu-item-safe-triangle-submenu-end-ySpecifies the y-coordinate where the submenu's safe triangle ends.

Slots

NameDescription
defaultThe default slot for the menu item.
startThe slot for the start of the menu item.
endThe slot for the end of the menu item.
submenuThe slot for the submenu of the menu item.