Primitives
Display arbitrary content inside floating panels.
Import the Popover primitives from ng-primitives/popover
.
import { NgpPopover } from 'ng-primitives/popover';
Assemble the popover directives in your template.
<button [ngpPopoverTrigger]="popover">Click me</button>
<ng-template #popover>
<div ngpPopover>Popover content</div>
</ng-template>
The following directives are available to import from the ng-primitives/popover
package:
Apply the ngpPopover
directive to an element that represents the popover. This typically would be a div
inside an ng-template
.
[ngpPopover]
ngpPopover
Apply the ngpPopoverTrigger
directive to an element that triggers the popover to show.
[ngpPopoverTrigger]
ngpPopoverTrigger
Attribute | Description | Value |
---|---|---|
data-state |
The state of the popover. | closed | closing | open | opening |
data-disabled |
Applied when the popover is disabled. | - |
You can configure the default options for all popovers in your application by using the provideNgpPopoverConfig
function in a providers array.
import { provideNgpPopoverConfig } from 'ng-primitives/popover';
bootstrapApplication(AppComponent, {
providers: [
provideNgpPopoverConfig({
offset: 4,
placement: 'top',
showDelay: 0,
hideDelay: 0,
flip: true,
container: document.body,
closeOnOutsideClick: true,
}),
],
});
Copyright © 2024 Angular Primitives