Primitives
A menu is a list of options or commands presented to the user in a dropdown list.
Import the Menu primitives from ng-primitives/menu
.
import { NgpMenu, NgpMenuItem, NgpMenuTrigger } from 'ng-primitives/menu';
The Menu primitives are a thin wrapper around the Angular CDK Menu directives. As a result you will need to import the Angular CDK overlay styles in your application.
@import '@angular/cdk/overlay-prebuilt.css';
Assemble the menu directives in your template.
<button [ngpMenuTrigger]="menu" ngpButton></button>
<ng-template #menu>
<div ngpMenu>
<div ngpMenuItem>Item 1</div>
<div ngpMenuItem>Item 2</div>
<div ngpMenuItem>Item 3</div>
</div>
</ng-template>
The following directives are available to import from the ng-primitives/menu
package:
The NgpMenuTrigger
directive allows you to turn an element into a menu trigger.
[ngpMenuTrigger]
ngpMenuTrigger
The following data attributes are available on the NgpMenuTrigger
directive:
Attribute | Description |
---|---|
data-open |
Applied when the menu is open. |
The NgpMenu
is a container for menu items.
[ngpMenu]
ngpMenu
The NgpMenuItem
directive represents a menu item.
[ngpMenuItem]
ngpMenuItem
The following data attributes are available on the NgpMenuItem
directive:
Attribute | Description |
---|---|
data-disabled |
Applied when the item is disabled. |
Copyright © 2024 Angular Primitives