ngbtooltip

ngbtooltip

ngbtooltip is the API of ng-bootstrap that is used to provide some extra information to the user on hover. In the angular project, we can easily add tooltip by using the ng-bootstrap.

Create a new project and add bootstrap to your project by the following code.

$ npm install --save @ng-bootstrap/ng-bootstrap

After installing the bootstrap into your project, you can add easily tooltip into your project as showing in the following.

<button type="button" class="btn btn-outline-secondary mr-2" placement="top" ngbTooltip="Tooltip on top">
  Tooltip on top
</button>
ngbtooltip

Left-Side Tooltip

If you want to show your tooltip on the left side of the button, so you can use the following code to add the tooltip on the left side of the button.

<button type="button" class="btn btn-outline-secondary mr-2" placement="left" ngbTooltip="Tooltip on left">
  Tooltip on left
</button>
ngbtooltip

Right-Side Tooltip

If you want to show your tooltip on the right side of the button, so you can use the following code to add the tooltip on the right side of the button.

<button type="button" class="btn btn-outline-secondary mr-2" placement="right" ngbTooltip="Tooltip on right">
  Tooltip on right
</button>
ngbtooltip

Bottom Tooltip

If you want to show your tooltip on the bottom of the button, so you can use the following code to add the tooltip on the bottom of the button.

<button type="button" class="btn btn-outline-secondary mr-2" placement="bottom" ngbTooltip="Tooltip on bottom">
  Tooltip on bottom
</button>
ngbtooltip

Ngbtooltip with HTML Tags.

We can easily add any HTML tags in the tooltip. Like if you want to show your text bold, italic, underline, overline, etc so, you can easily use HTML with the tooltip. As showing in the following example showing tooltip text with bold.

<ng-template #tipContent>Hello, <b>{{name}}</b>!</ng-template>
<button type="button" class="btn btn-outline-secondary" [ngbTooltip]="tipContent">
  I've got markup and bindings in my tooltip!
</button>
ngbtooltip

On-Click Tooltip

If you want to show your tooltip when someone clicks on the button then show tooltip information. You can easily add an on-click tooltip by using the following code.

<button type="button" class="btn btn-outline-secondary" ngbTooltip="You see, I show up on click!" triggers="click:blur">
  Click me!
</button>

Tooltip Delays

If you want to add some delays into your tooltip after on hover the button so you can easily add delays in your project. See the following code it’s showing delays into your project tooltip.

<button type="button" class="btn btn-outline-secondary mr-2"
  ngbTooltip="You see, I show up after 300ms and disappear after 500ms!"
  [openDelay]="300" [closeDelay]="500">
  Hover 300ms here
</button>
<button type="button" class="btn btn-outline-secondary mr-2"
  ngbTooltip="You see, I show up after 1s and disappear after 2s!"
  [openDelay]="1000" [closeDelay]="2000">
  Hover 1s here
</button>

Reference

https://ng-bootstrap.github.io/#/components/tooltip/api

Visit the angular tutorial list. And make strong your angular concept. click here. wuschools.com is always written about the Agular concept for the angular lover. Ang writes about how angular makes your life easy if you are a web site developer.

Leave a Reply

Close Menu