Angular Tooltip with HTML Content Example

By Hardik Savani May 2, 2024 Category : Angular


This article will provide example of angular tooltip with html content example. you can understand a concept of angular custom tooltip with html content. In this article, we will implement a angular 12 tooltip with html content. step by step explain angular material tooltip with html content.

Sometime we need to add tooltip with html content because we need to display some text as bold or as title so, here we will use npm ng2-tooltip-directive package for adding tooltip with html content. you can use this example with in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11, angular 12, angular 13, angular 14, angular 15, angular 16 and angular 17 version app.


Step 1: Create New App

You can easily create your angular app using bellow command:

ng new myNewApp

Step 2: Install ng2-tooltip-directive npm Package

Now in this step, we need to just install ng2-tooltip-directive in our angular application. so let's add as like bellow:

npm i ng2-tooltip-directive

Step 3: Import TooltipModule

we will import TooltipModule module as like bellow code:


import { NgModule } from '@angular/core';

import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

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


declarations: [



imports: [




providers: [],

bootstrap: [AppComponent]


export class AppModule { }

Step 4: Update HTML File

here, we need to update html file as like bellow code:


<h1>Angular Tooltip with HTML Content Example -</h1>

<button placement="top" tooltip="<p>Hello i'm a <strong>bold</strong> text!</p>">

Ex 1: Tooltip with HTML content


<ng-template #HtmlContent>

<p>Hello i'm a <strong>bold</strong> text!</p>


<button [tooltip]="HtmlContent" contentType="template">

Ex 2: Tooltip with template content


Now you can run by bellow command:

ng serve

now you can check it.

I hope it can help you...

Tags :