2.10.3 • Published 3 years ago

ng2-tooltip-directive v2.10.3

Weekly downloads
21,896
License
MIT
Repository
github
Last release
3 years ago

Tooltip for Angular

Build Status

The tooltip is a pop-up tip that appears when you hover over an item or click on it.

🔬️ Help make Tooltips better by answering a few questions.

Demo

http://ivylab.space/tooltip

Installation

Install the npm package.

npm i ng2-tooltip-directive
    

Import Ng2Module:

import { TooltipModule } from 'ng2-tooltip-directive';
 
@NgModule({
    imports: [ TooltipModule ]
}) 

Usage

Options can be set in the directive tag, so they have the highest priority.

<span tooltip="Tooltip" placement="top" showDelay="500">Tooltip on top</span>

You may pass as an object:

<span tooltip="Tooltip" [options]="myOptions">Tooltip on left</span>
myOptions = {
    'placement': 'left',
    'showDelay': 500
}

You can pass HTML as content :

<span tooltip="<p>Hello i'm a <strong>bold</strong> text!</p>">
  Tooltip with HTML content
</span>
<ng-template #HtmlContent>
  <p>Hello i'm a <strong>bold</strong> text!</p>
</ng-template>

<span [tooltip]="HtmlContent" contentType="template">
  Tooltip with template content
</span>

Set default values

Create a file with your settings, for example:

import { TooltipOptions } from 'ng2-tooltip-directive';

export const MyDefaultTooltipOptions: TooltipOptions = {
  'show-delay': 500
}

And pass your parameters when importing the module:

import { TooltipModule, TooltipOptions } from 'ng2-tooltip-directive';
import { MyDefaultTooltipOptions } from './my-default-options';
 
@NgModule({
    imports: [ 
      TooltipModule.forRoot(MyDefaultTooltipOptions as TooltipOptions)
    ]
})

Properties

nametypedefaultdescription
placement"top", "bottom", "left", "right""top"The position of the tooltip.
autoPlacementbooleantruePlace the tooltip so that it does not go beyond the borders of the browser window.
showDelaynumber0The delay in ms before showing the tooltip.
hideDelaynumber300The delay in ms before removing the tooltip.
hideDelayTouchscreennumber0Delay in milliseconds before hiding the tooltip (for mobile devices).
displaybooleantrueTooltip availability for display.
displayTouchscreenbooleantrueDisplay the tooltip on mobile devices.
zIndexnumber0Z-index of the tooltip.
trigger"hover", "click""hover"Specifies how the tooltip is triggered. Control the closing time with "hide-delay".
tooltipClassstringClasses to be passed to the tooltip.
animationDurationnumber300The duration controls how long the animation takes to run from start to finish.
theme"dark", "light""dark"Theme of tooltip background and text.
shadowbooleantrueShadow of the tooltip.
offsetnumber8Offset the tooltip relative to the item.
widthnumberundefinedWidth of the tooltip.
maxWidthnumber200Maximum width of the tooltip.
contentType"string", "html', "template""string"The content type passed to the tooltip.
hideDelayAfterClicknumber2000Tooltip hiding delay for "click" trigger.
pointerEvents"auto", "none""none"Defines whether or not an element reacts to pointer events.
position{top: number, left: number}undefinedThe tooltip coordinates relative to the browser window.

Events

When you call events, the delays that are specified in the options in the directive are taken into account. Default delay before tooltip hiding is 300 milliseconds.

EventDescription
{type: "show", position: DOMRect}The event is called before the tooltip appears.
{type: "shown", position: DOMRect}The event is called after the animation of the appearance of the tooltip.
{type: "hide", position: DOMRect}The event is called before the tooltip is hidden.
{type: "hidden", position: DOMRect}The event is called after the animation of the tooltip is hidden.

Methods

If you specified the directive options, they will be taken into account when calling methods. Including the delay before the appearance and hiding of the tooltip.

MethodDescription
show()Shows the tooltip
hide()Hides the tooltip

Author services

Are you interested in this library but lacks features? Write to the author, he can do it for you.

Sponsors

We use Browserstack for cross-browser testing.

Browserstack

2.10.3

3 years ago

2.10.2

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.22

4 years ago

2.9.21

4 years ago

2.9.20

4 years ago

2.9.19

4 years ago

2.9.18

4 years ago

2.9.17

4 years ago

2.8.17

5 years ago

2.7.17

5 years ago

2.7.16

5 years ago

2.7.15

5 years ago

2.7.14

5 years ago

2.6.14

5 years ago

2.6.13

5 years ago

2.5.13

5 years ago

2.4.12

5 years ago

2.3.12

5 years ago

2.2.12

5 years ago

2.2.11

5 years ago

2.2.10

5 years ago

2.2.9

5 years ago

2.1.9

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago