packages/components/layout/eui-app/eui-app-sidebar/sidebar-menu/sidebar-menu.component.ts
Sidebar navigation menu component that renders hierarchical menu items within the application sidebar. Integrates with EuiAppShellService to synchronize menu state and handle responsive behavior. Supports filtering, icons, tooltips, collapsible states, and automatic closure on mobile/tablet navigation. Automatically switches between sidebar-only and combined menu items based on viewport breakpoints.
Example :<!-- Basic sidebar menu within app structure -->
<eui-app>
<eui-app-sidebar>
<eui-app-sidebar-body>
<eui-app-sidebar-menu
[items]="sidebarItems"
[hasFilter]="true"
[hasIcons]="true"
(sidebarItemClick)="onMenuItemClick($event)"
(sidebarItemToggle)="onMenuItemToggle($event)">
</eui-app-sidebar-menu>
</eui-app-sidebar-body>
</eui-app-sidebar>
</eui-app>import { EuiMenuItem } from '@eui/components/eui-menu';
sidebarItems: EuiMenuItem[] = [
{
label: 'Dashboard',
url: '/dashboard',
icon: 'home:outline'
},
{
label: 'Settings',
icon: 'settings:outline',
children: [
{ label: 'Profile', url: '/settings/profile' },
{ label: 'Security', url: '/settings/security' }
]
}
];
onMenuItemClick(item: EuiMenuItem): void {
console.log('Menu item clicked:', item);
}
OnInit
AfterViewInit
OnChanges
OnDestroy
| encapsulation | ViewEncapsulation.None |
| selector | eui-app-sidebar-menu |
| imports |
AsyncPipe
EUI_MENU
|
| templateUrl | ./sidebar-menu.component.html |
Properties |
Methods |
|
Inputs |
Outputs |
HostBindings |
constructor()
|
| expandAllItems |
Type : boolean
|
Default value : false
|
|
Expands all collapsible menu items by default. When true, all parent menu items with children are rendered in expanded state on initialization. |
| hasBoldRootLevel |
Type : boolean
|
Default value : false
|
|
Applies bold font weight to root-level menu items. When true, emphasizes top-level menu items with bold styling to distinguish hierarchy. |
| hasCollapsedInitials |
Type : boolean
|
Default value : false
|
|
Displays initials instead of full icons in collapsed mode. When true, shows first letter of menu item label as a visual identifier when sidebar is collapsed. |
| hasFilter |
Type : boolean
|
Default value : false
|
|
Enables a search/filter input field above the menu items. When true, displays a text input allowing users to filter menu items by label. |
| hasIcons |
Type : boolean
|
Default value : false
|
|
Displays icons alongside menu item labels. When true, renders icon elements for menu items that have icon definitions. |
| hasIconsLabels |
Type : boolean
|
Default value : false
|
|
Shows icon labels in collapsed sidebar mode. When true, displays text labels below icons when sidebar is collapsed, enabling icon-with-label variant. |
| hasScrollToItem |
Type : boolean
|
Default value : false
|
|
Enables automatic scrolling to active menu item. When true, scrolls the menu container to bring the currently active item into view. |
| hasTooltip |
Type : boolean
|
Default value : true
|
|
Enables tooltips on menu items when sidebar is collapsed. When true, displays full menu item labels in tooltips on hover in collapsed state. |
| hasTooltipOnExpanded |
Type : boolean
|
Default value : false
|
|
Shows tooltips even when sidebar is expanded. When true, displays tooltips on menu items regardless of sidebar collapse state. |
| isCollapsed |
Type : boolean
|
Default value : false
|
|
Renders the menu in collapsed/icon-only mode. When true, hides menu item labels and shows only icons, typically synchronized with sidebar collapse state. |
| isFlat |
Type : boolean
|
Default value : false
|
|
Renders menu in flat mode without hierarchical indentation. When true, all menu items are displayed at the same level regardless of parent-child relationships. |
| sidebarItemClick |
Type : EventEmitter
|
|
Emitted when a menu item is clicked by the user. Payload: EuiMenuItem - the clicked menu item object Triggered on any menu item click, before automatic sidebar closure on mobile/tablet. |
| sidebarItemToggle |
Type : EventEmitter
|
|
Emitted when a collapsible menu item is expanded or collapsed. Payload: EuiMenuItem - the toggled menu item object Triggered when user clicks the expand/collapse control on parent menu items. |
| class |
Type : string
|
Default value : 'eui-app-sidebar-menu'
|
| Public onMenuItemClicked | ||||||
onMenuItemClicked(event: EuiMenuItem)
|
||||||
|
Parameters :
Returns :
void
|
| Public onSidebarItemToggled | ||||||
onSidebarItemToggled(event: EuiMenuItem)
|
||||||
|
Parameters :
Returns :
void
|
| asService |
Type : unknown
|
Default value : inject(EuiAppShellService)
|
| class |
Type : string
|
Default value : 'eui-app-sidebar-menu'
|
Decorators :
@HostBinding()
|
| Optional menu |
Type : EuiMenuComponent
|
Decorators :
@ViewChild('menu', {static: false})
|