ngx-popperjs

ngx-popperjs is an angular wrapper for the FloatingUI library (v ^1.5.3).
VERY IMPORTANT READ THIS
I'm moving this to the top because it appears that people don't get to reading it in the contribute section.
FOR THIS LIBRARY PLEASE USE ISSUES ONLY FOR BUG REPORTING. DON'T OPEN ISSUES SUCH AS "I need upgrade for Angular 1745646456" especially if Angular 1745646456 was released a few days ago.
I guarantee that I manage the updates AS SOON AS POSSIBLE. But as you understand this is not a paying job, so you can't get Angular 1745646456 the day it gets released.
ISSUES NOT RESPECTING THIS WILL BE DELETED IMMEDIATELY WITHOUT ANY RESPONSE.
Thank you.
NOW USING FLOATING UI - UPGRADING TO V17
If you used previous versions of ngx-popperjs, you'll now that it wrapped popper.js initially.
Since Floating UI is the future version of Popper.js and since latest happenings with recent Chrome updates breaking ngx-popperjs, I decided to move to the newer technology.
What impacts does it have for the library?
Well on a graphic perspective, none. You will be able to use the v17 without changing any stylings.
The only deprecation is in the NgxPopperjsOptions
which now doesn't provide the modifiers.
The reason is that you can't now pass modifiers like you did in Popper.js.
It didn't seem like a huge change, since in this library modifiers should be mostly (but let me know with an issue) for preventing the popper flipping.
Now by default, popovers won't flip. You will have to pass popperPreventOverflow
as attribute (coerced so the empty attribute will suffice) to make the popovers flip.
I will be publishing the new ngx-floating-ui (still contending for the name on npm) along this one.
The goal is gradually moving everybody to ngx-floating-ui. So I will probably publish both for this and the next major (18), then deprecate this package in favor of the new one.
Clearly switching to the new package will require some work, cause I can't have a library called "ngx-floating-ui" and then modules called "NgxPopperjs".
It will be worth it though cause there's much more potential in Floating UI, and we will be able to include new features, such as combobox or dialog as shown on their website.
Check NgxPopperjs official page to be updated!
Premise
The goal of this library is to take Mr Frankel's ngx-popper and update the compatibility for more recent versions of Angular.
Since the old library is compatible with Angular 7 and earlier, I started with Angular 8.
If you need to work with an older version of Angular (5 to 7), please refer to Mr Frankel's ngx-popper.
From v15.2.0:
Since many complained about using the NgxPopperjsPlacements
enum, I added a version of the popper directive which accepts a plain string as placement!
Now you can use it with all the options of the classic popper, but you'll have to use:
popperLoose
instead of popper
and
popperLoosePlacement
instead of popperPlacement
Installation
node and npm are required to run this package.
- Use npm/yarn to install the package:
$ npm install @floating-ui/dom ngx-popperjs --save
Or
$ yarn add @floating-ui/dom --save
$ yarn add ngx-popperjs --save
- You simply add into your module
NgxPopperjsModule
:
import {NgxPopperjsModule} from 'ngx-popperjs';
@NgModule({
imports: [
NgxPopperjsModule
]
})
Optionally you can include in your styles.css
/ styles.css
one of the prebuilt themes:
-
@import node_modules/ngx-popperjs/css/theme-dark.css
-
@import node_modules/css/theme-white.css
-
@use ngx-popperjs/scss/theme as popperBaseTheme
-
@use ngx-popperjs/scss/theme-dark as popperDarkTheme
-
@use ngx-popperjs/scss/theme-white popperWhiteTheme
or easily create your own theme using the @mixin:
@use "ngx-popperjs/scss/theme" as popperBaseTheme;
body {
@include popperjs.ngx-popperjs-theme($background-color, $text-color, $max-width, $z-index);
}
<popper-content #popper1Content>
<p class="bold">Popper on bottom</p>
</popper-content>
<div [popper]="popper1Content"
[popperShowOnStart]="true"
[popperTrigger]="'click'"
popperHideOnClickOutside
[popperHideOnScroll]="true"
[popperPlacement]="'bottom'">
<p class="bold">Hey!</p>
<p class="thin">Choose where to put your popper!</p>
</div>
<div popper="As text"
[popperTrigger]="'hover'"
[popperPlacement]="'bottom'"
(popperOnShown)="onShown($event)">
<p class="bold">Pop</p>
<p class="thin">on the bottom</p>
</div>
<div popper="{{someTextProperty}}"
[popperTrigger]="'hover'"
[popperPlacement]="'bottom'"
[popperStyles]="{'background-color: 'blue''}"
(popperOnShown)="onShown($event)">
<p class="bold">Pop</p>
<p class="thin">on the bottom</p>
</div>
- Position fixed, breaking overflow:
<div popper="As text"
[popperTrigger]="'hover'"
[popperPlacement]="'bottom'"
[popperPositionFixed]="true"
(popperOnShown)="onShown($event)">
</div>
<div class="example">
<div #popperTargetElement></div>
<div popper="As text"
popperTrigger="hover"
popperPlacement="bottom"
[popperTarget]="popperTargetElement.nativeElement"
(popperOnShown)="onShown($event)">
</div>
- hide/show programmatically:
<div [popper]="tooltipcontent"
popperTrigger="hover"
popperPlacement="bottom"
[popperApplyClass]="'popperSpecialStyle'">
<p class="bold">Pop</p>
<p class="thin">on the bottom</p>
</div>
<popper-content #tooltipcontent>
<div>
<p>This is a tooltip with text</p>
<span (click)="tooltipcontent.hide()">Close</span>
</div>
</popper-content>
NgModule({
imports: [
BrowserModule,
FormsModule,
NgxPopperjsModule.forRoot({placement: NgxPopperjsPlacements.TOP})],
declarations: [AppComponent],
providers: [],
bootstrap: [AppComponent]
});
showDelay | number | 0 |
disableAnimation | boolean | false |
disableDefaultStyling | boolean | false |
placement | Placement(string) | auto |
boundariesElement | string(selector) | undefined |
trigger | Trigger(string) | hover |
positionFixed | boolean | false |
hideOnClickOutside | boolean | true |
hideOnMouseLeave | boolean | false |
hideOnScroll | boolean | false |
applyClass | string | undefined |
styles | Object | undefined |
applyArrowClass | string | undefined |
ariaDescribeBy | string | undefined |
ariaRole | string | undefined |
appendTo | string | undefined |
preventOverflow | boolean | undefined |
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-start'
| 'bottom-start'
| 'left-start'
| 'right-start'
| 'top-end'
| 'bottom-end'
| 'left-end'
| 'right-end'
| 'auto'
| 'auto-start'
| 'auto-end'
| Function
| 'click'
| 'mousedown'
| 'hover'
| 'none'
Demo site with sample codes
Demo of ngx-popperjs
Contribute
You can only report bugs. Every other issue will be deleted right away.
$ npm install
$ npm run start //run example
Special thanks
Jetbrains is now supporting this library with an open-source license, which will allow a better code! 🎉

License
This project is licensed under the MIT License - see the LICENSE file for details
Thanks to
MrFrankel for setting up ngx-popper and maintaining till v 7.0.0.