ngx-popperjs vs @ngneat/helipopper
Angular Popper.js Integrations Comparison
3 Years
ngx-popperjs@ngneat/helipopperSimilar Packages:
What's Angular Popper.js Integrations?

Both @ngneat/helipopper and ngx-popperjs are Angular libraries designed to facilitate the integration of Popper.js, a powerful positioning engine for tooltips and popovers. They provide developers with the ability to create dynamic and responsive UI elements that can be positioned relative to other elements on the page. While both libraries serve a similar purpose, they differ in terms of features, ease of use, and customization options, making them suitable for different types of projects and developer preferences.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
ngx-popperjs17,209
67253 kB08 months agoMIT
@ngneat/helipopper15,304
439125 kB2916 days agoMIT
Feature Comparison: ngx-popperjs vs @ngneat/helipopper

API Design

  • ngx-popperjs:

    ngx-popperjs offers a simpler API that is easy to understand and implement. It focuses on providing essential features for tooltips and popovers without overwhelming developers with advanced options, making it suitable for quick implementations.

  • @ngneat/helipopper:

    @ngneat/helipopper provides a more modern and Angular-centric API that leverages Angular's reactive programming principles. It allows developers to easily manage the lifecycle of poppers through Angular's dependency injection and change detection, resulting in a more intuitive integration with Angular applications.

Customization Options

  • ngx-popperjs:

    ngx-popperjs offers basic customization options but may be limited compared to @ngneat/helipopper. It is suitable for developers who need standard tooltip and popover features without the need for deep customization.

  • @ngneat/helipopper:

    @ngneat/helipopper allows for extensive customization of popper behavior and appearance. Developers can easily modify the positioning, styling, and animations of poppers, providing greater control over the user experience.

Integration with Angular Features

  • ngx-popperjs:

    While ngx-popperjs can be integrated with Angular, it does not leverage Angular's reactive features as effectively as @ngneat/helipopper. This may lead to more manual management of state and updates.

  • @ngneat/helipopper:

    This package is designed to work seamlessly with Angular's reactive features, such as observables and change detection. This makes it easier to manage dynamic content and updates, ensuring that poppers behave correctly in response to application state changes.

Performance

  • ngx-popperjs:

    ngx-popperjs provides decent performance but may not be as optimized for Angular's change detection and lifecycle management, potentially leading to unnecessary re-renders in certain scenarios.

  • @ngneat/helipopper:

    @ngneat/helipopper is optimized for performance in Angular applications, ensuring that poppers are rendered efficiently and only when necessary. This can lead to improved application responsiveness, especially in complex UIs.

Documentation and Community Support

  • ngx-popperjs:

    ngx-popperjs has basic documentation, which may be sufficient for simple use cases but might lack depth for more complex implementations. The community support may also be less active compared to @ngneat/helipopper.

  • @ngneat/helipopper:

    @ngneat/helipopper has comprehensive documentation and an active community, making it easier for developers to find resources, examples, and support when implementing the library in their projects.

How to Choose: ngx-popperjs vs @ngneat/helipopper
  • ngx-popperjs:

    Choose ngx-popperjs if you prefer a straightforward implementation with a focus on simplicity and ease of use. It is suitable for projects that require basic tooltip and popover functionality without the need for extensive customization or advanced features.

  • @ngneat/helipopper:

    Choose @ngneat/helipopper if you need a more modern and flexible API that integrates seamlessly with Angular's reactive programming model. It offers better support for Angular features like observables and change detection, making it ideal for applications that require dynamic positioning and responsiveness.

README for ngx-popperjs

ngx-popperjs

npm npm MIT licensed Build state Size Rate this package

ngx-popperjs is an angular wrapper for the FloatingUI library (v ^1.5.3).

VERY IMPORTANT READ THIS

With v17 ngx-popperjs won't get any updates. That's because from v17 it's not actually using popper.js anymore.

I developed ngx-float-ui and released v17 at the same time of this. My suggestion is to migrate to that one. In 6 months from the release, this version will be marked as deprecated. Since the new library isn't affected by the "Chrome 110 bug" I would suggest to migrate earlier versions as well. If you open an issue on ngx-float-ui asking for a certain version (or search for an open issue for that version and leave a thumb), I will publish earlier versions as well.

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. Maybe if we see that it can be useful we can pass an override for the middleware.

I simply added a new attribute, popperFlip, that you can set to false, in order to prevent the flipping (default true).

Check NgxPopperjs official page to stay up to date!

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.

  1. 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 
  1. 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);
}
  1. Add to view:
 <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>
  1. As text:
     <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>
  1. Position fixed, breaking overflow:
     <div popper="As text"
          [popperTrigger]="'hover'"
          [popperPlacement]="'bottom'"
          [popperPositionFixed]="true"
          (popperOnShown)="onShown($event)">
     </div>
  1. Specific target:
<div class="example">
     <div #popperTargetElement></div>
     <div popper="As text"
          popperTrigger="hover"
          popperPlacement="bottom"
          [popperTarget]="popperTargetElement.nativeElement"
          (popperOnShown)="onShown($event)">
     </div>
  1. 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>
  1. Attributes map:

    | Option | Type | Default | Description | |:-------------------------|:------------------|:----------|:---------------------------------------------------------------------------------------| | popperDisableAnimation | boolean | false | Disable the default animation on show/hide | | popperDisableStyle | boolean | false | Disable the default styling | | popperDisabled | boolean | false | Disable the popper, ignore all events | | popperDelay | number | 0 | Delay time until popper it shown | | popperTimeout | number | 0 | Set delay before the popper is hidden | | popperTimeoutAfterShow | number | 0 | Set a time on which the popper will be hidden after it is shown | | popperPlacement | Placement(string) | auto | The placement to show the popper relative to the reference element | | popperTarget | HtmlElement | auto | Specify a different reference element other the the one hosting the directive | | popperBoundaries | string(selector) | undefined | Specify a selector to serve as the boundaries of the element | | popperShowOnStart | boolean | false | Popper default to show | | popperTrigger | Trigger(string) | click | Trigger/Event on which to show/hide the popper | | popperPositionFixed | boolean | false | Set the popper element to use position: fixed | | popperAppendTo | string | undefined | append The popper-content element to a given selector, if multiple will apply to first | | popperPreventOverflow | boolean | undefined | Prevent the popper from being positioned outside the boundary | | popperHideOnClickOutside | boolean | true | Popper will hide on a click outside | | popperHideOnScroll | boolean | false | Popper will hide on scroll | | popperHideOnMouseLeave | boolean | false | Popper will hide on mouse leave | | popperApplyClass | string | undefined | list of comma separated class to apply on ngpx__container | | popperStyles | Object | undefined | Apply the styles object, aligned with ngStyles | | popperApplyArrowClass | string | undefined | list of comma separated class to apply on ngpx__arrow | | popperOnShown | EventEmitter<> | $event | Event handler when popper is shown | | popperOnHidden | EventEmitter<> | $event | Event handler when popper is hidden | | popperOnUpdate | EventEmitter<> | $event | Event handler when popper is updated | | popperAriaDescribeBy | string | undefined | Define value for aria-describeby attribute | | popperAriaRole | string | popper | Define value for aria-role attribute | | popperFlip | boolean | true | Enable or disable the flipping |

  2. Override defaults:

    ngx-popperjs comes with a few default properties you can override in default to effect all instances These are overridden by any child attributes.

NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    NgxPopperjsModule.forRoot({placement: NgxPopperjsPlacements.TOP})],
  declarations: [AppComponent],
  providers: [],
  bootstrap: [AppComponent]

});

| Options | Type | Default | |:------------------- |:---------------- |:--------- | | 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 |

  1. popperPlacement:

| '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

  1. popperTrigger:

| '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

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.