shy2net / nemex-angular2-tooltip

An advanced yet simple and highly customizable Angular 2+ tooltip
http://byshynet.com
1 stars 0 forks source link
angular2 angular2-tooltip tooltip typescript

Advanced Angular 2 Tooltip

This package allows you to create highly customizable or simple tooltips easily. It supports adding HTML content such as buttons just like Facebook user profile tooltip, or you can just use it as a simple tooltip.

It features the following:

It looks like the following (by default):

Angular2 tooltip example

It comes with an example code containg the following: Angular2 tooltip example

Tooltip installation

Install the package using the following command:

npm install nemex-angular2-tooltip --save

In your app module add the following code:

...
import { NemexTooltipModule, TooltipService } from 'nemex-angular2-tooltip';

@NgModule({
  ...
  // Import the module in order to add the tooltip directive
  imports: [
    ...
    NemexTooltipModule
  ],
  // Add the tooltip service to your list of providers in order to easily configure it globally
  providers: [ 
    ...
    TooltipService
  ],
  ...
})

Now to your component html add the following:

<div tooltip tooltipContent="I'm a nice tooltip!">
    ...
</div>

If you want to use HTML inside of your tooltip, use the following:

<div tooltip>
    <div class="tooltip-content">
        <!-- Any custom content goes here -->
        <button>Just a simple tooltip button!</button>
    </div>
    ...
</div>

Advanced features

The tooltip can be customized using simple properties such as:

<!-- Creates a tooltip positioned to the right of the element -->
<div tooltip tooltipContent="Hello there!" tooltipPlacement="right">
    ...
</div>

This tooltip supports the following properties:

Editing the default configurations

You can edit the default tooltip configurations easily, by simply accessing the TooltipService and editing the following members:

An example of editing the default tooltip style is by injecting the service into the app component:

import { Component } from '@angular/core';
import { TooltipService } from 'nemex-angular2-tooltip';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';

  public constructor(private tooltipService:TooltipService) {
    tooltipService.defaultTooltipStyle =
      `background: #000;
       color: #fff;
       padding: 5px;`;
  }
}