Navigation Menu for M3E
npm install @m3e/nav-menum3e-nav-menu component provides a hierarchical, accessible navigation menu. Designed for sidebars, navigation drawers, and complex menu structures, it supports nested expandable items, keyboard navigation, selection, and extensive theming via CSS custom properties.
bash
npm install @m3e/nav-menu
`
๐ป Editor Integration
This package includes a Custom Elements Manifest to support enhanced editor tooling and developer experience.
$3
To enable autocomplete and hover documentation for @m3e/nav-menu, install the Custom Elements Manifest Language Server extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.
Alternately, you can explicitly reference the html-custom-data.json and css-custom-data.json in your workspace settings:
`json
{
"html.customData": ["./node_modules/@m3e/nav-menu/dist/html-custom-data.json"],
"css.customData": ["./node_modules/@m3e/nav-menu/dist/css-custom-data.json"]
}
`
๐ Native Module Support
This package uses JavaScript Modules. To use it directly in a browser without a bundler, use a module script similar to the following.
`html
`
In addition, you must use an import map to include dependencies.
`html
`
> For production, use index.min.js, a11y.min.js, and bidi.min.js for faster load times.
๐๏ธ Elements
- m3e-nav-menu โ A hierarchical menu, typically used on larger devices, that allows a user to switch between views.
- m3e-nav-menu-item โ An expandable item, selectable item within a navigation menu.
- m3e-nav-menu-item-group โ A top-level semantic grouping of items in a navigation menu.
๐งช Examples
The following example illustrates a navigation menu with a top-level group of menu items.
`html
Mail
Inbox
24
Outbox
Favorites
Trash
`
The next example illustrates a multilevel navigation menu.
`html
Getting Started
Overview
Installation
Actions
Button
Icon
Icon Button
`
๐ API Reference
$3
This section details the slots and CSS custom properties available for the m3e-nav-menu component.
#### ๐งฉ Slots
| Slot | Description |
| ----------- | ------------------------------ |
| _(default)_ | Renders the items of the menu. |
#### ๐๏ธ CSS Custom Properties
| Property | Description |
| -------------------------------- | ---------------------------------------- |
| --m3e-nav-menu-padding-top | Top padding for the menu. |
| --m3e-nav-menu-padding-bottom | Bottom padding for the menu. |
| --m3e-nav-menu-padding-left | Left padding for the menu. |
| --m3e-nav-menu-padding-right | Right padding for the menu. |
| --m3e-nav-menu-divider-margin | Margin for divider elements in the menu. |
| --m3e-nav-menu-scrollbar-width | Width of the menu scrollbar. |
| --m3e-nav-menu-scrollbar-color | Color of the menu scrollbar. |
$3
This section details the attributes, slots, events, and CSS custom properties available for the m3e-nav-menu-item component.
#### โ๏ธ Attributes
| Attribute | Type | Default | Description |
| --------------- | --------- | ------- | ----------------------------------------------------------- |
| disabled | boolean | false | Whether the item is disabled. |
| indeterminate | boolean | false | Whether the item's selected/checked state is indeterminate. |
| open | boolean | false | Whether the item is expanded. |
| selected | boolean | false | Whether the item is selected. |
#### ๐ Events
| Event | Description |
| --------- | -------------------------------------- |
| opening | Emitted when the item begins to open. |
| opened | Emitted when the item has opened. |
| closing | Emitted when the item begins to close. |
| closed | Emitted when the item has closed. |
#### ๐งฉ Slots
| Slot | Description |
| --------------- | ------------------------------------------- |
| _(default)_ | Renders the nested child items. |
| label | Renders the label of the item. |
| icon | Renders the icon of the item. |
| selected-icon | Renders the icon of the item when selected. |
| toggle-icon | Renders the toggle icon. |
| badge | Renders a badge for the item. |
#### ๐๏ธ CSS Custom Properties
| Property | Description |
| ------------------------------------------------------ | --------------------------------------------- |
| --m3e-nav-menu-item-font-size | Font size for the item label. |
| --m3e-nav-menu-item-font-weight | Font weight for the item label. |
| --m3e-nav-menu-item-line-height | Line height for the item label. |
| --m3e-nav-menu-item-tracking | Letter spacing for the item label. |
| --m3e-nav-menu-item-padding | Inline padding for the item. |
| --m3e-nav-menu-item-height | Height of the item. |
| --m3e-nav-menu-item-spacing | Spacing between icon and label. |
| --m3e-nav-menu-item-shape | Border radius of the item and focus ring. |
| --m3e-nav-menu-item-icon-size | Size of the icon. |
| --m3e-nav-menu-item-inset | Indentation for nested items. |
| --m3e-nav-menu-item-label-color | Text color for the item label. |
| --m3e-nav-menu-item-selected-label-color | Text color for selected item label. |
| --m3e-nav-menu-item-selected-container-color | Background color for selected item. |
| --m3e-nav-menu-item-selected-container-focus-color | Focus color for selected item container. |
| --m3e-nav-menu-item-selected-container-hover-color | Hover color for selected item container. |
| --m3e-nav-menu-item-selected-ripple-color | Ripple color for selected item. |
| --m3e-nav-menu-item-unselected-container-focus-color | Focus color for unselected item container. |
| --m3e-nav-menu-item-unselected-container-hover-color | Hover color for unselected item container. |
| --m3e-nav-menu-item-unselected-ripple-color | Ripple color for unselected item. |
| --m3e-nav-menu-item-open-container-color | Background color for open item with children. |
| --m3e-nav-menu-item-open-container-focus-color | Focus color for open item container. |
| --m3e-nav-menu-item-open-container-hover-color | Hover color for open item container. |
| --m3e-nav-menu-item-open-ripple-color | Ripple color for open item. |
| --m3e-nav-menu-item-disabled-color | Text color for disabled item. |
| --m3e-nav-menu-item-disabled-color-opacity | Opacity for disabled item text color. |
| --m3e-nav-menu-item-badge-font-size | Font size for badge slot. |
| --m3e-nav-menu-item-badge-font-weight | Font weight for badge slot. |
| --m3e-nav-menu-item-badge-line-height | Line height for badge slot. |
| --m3e-nav-menu-item-badge-tracking | Letter spacing for badge slot. |
| --m3e-nav-menu-divider-margin | Margin for divider elements. |
| --m3e-nav-menu-item-vertical-inset | Vertical margin for first/last child items. |
$3
This section details the slots and CSS custom properties available for the m3e-nav-menu-item-group component.
#### ๐งฉ Slots
| Slot | Description |
| ----------- | ------------------------------- |
| _(default)_ | Renders the items of the group. |
| label | Renders the label of the group. |
#### ๐๏ธ CSS Custom Properties
| Property | Description |
| --------------------------------------- | -------------------------------------------------- |
| --m3e-nav-menu-item-group-label-inset | Insets the label from the start edge of the group. |
| --m3e-nav-menu-item-group-label-space | Vertical spacing around the group's label. |
๐ค Contributing
See the root monorepo CONTRIBUTING.md` for guidelines on contributing to this package.