Open In App

Angular MDBootstrap Tooltips Component

MDBootstrap is a Material Design and bootstrap-based Angular UI library that is used to make good-looking webpages with its seamless and easy-to-use component. In this article, we will know how to use Tooltips Component in Angular MDBootstap. Tooltips are used to provide interactive textual hints to the user about the element when the mouse pointer moves over. we can use the tooltip in any direction i.e. top, right, bottom, left. 

Important points:



Properties:

Syntax:



<button mdbTooltip="Top">Top</button>

Approach:

npm install
or 
npm install -y
cd appname
ng serve

Project Structure: After complete installation, it will look like the following:

Example 1: This is the basic example that illustrates how to use the Tooltips component.




<div id='gfg'>
  <h2>GeeksforGeeks</h2>
  <h4>Angular MDBootstrap Tooltips Component</h4>
  <br />
  <a mdbTooltip="GeeksforGeeks" placement="top">Hover Here</a>
</div>




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




import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from 
    '@angular/platform-browser/animations';
  
import { AppComponent } from './app.component';
  
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MDBBootstrapModule.forRoot(),
    FormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Output:

Example 2: In this example, we will know hot add tooltips in a button




<div id='gfg'>
  <h2>GeeksforGeeks</h2>
  <h4>Angular MDBootstrap Tooltips Component</h4>
  <br />
  <button type="button" mdbBtn color="info" 
    class="bwaves-light" mdbTooltip="Tooltip on top" 
    placement="top" mdbWavesEffect>
    Top
  </button>
  
  <button type="button" mdbBtn color="danger" 
    class="waves-light" mdbTooltip="Tooltip on right"
    placement="right" mdbWavesEffect>
    Right
  </button>
  
  <button type="button" mdbBtn color="warning"
    class="waves-light" mdbTooltip="Tooltip on bottom"
    placement="bottom" mdbWavesEffect>
    Bottom
  </button>
  
  <button type="button" mdbBtn color="success" 
    class="waves-light" mdbTooltip="Tooltip on left"
    placement="left" mdbWavesEffect>
    Left
  </button>
</div>




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




import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from 
    '@angular/platform-browser/animations';
  
import { AppComponent } from './app.component';
  
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MDBBootstrapModule.forRoot(),
    FormsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Output:

Reference: https://mdbootstrap.com/docs/angular/advanced/tooltips/


Article Tags :