Skip to content
Related Articles
Open in App
Not now

Related Articles

How to use matTooltip in Angular Material ?

Improve Article
Save Article
  • Last Updated : 08 Feb, 2021
Improve Article
Save Article

Angular Material is a UI component library developed by Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have done it you can enter the below command and can download it. matTooltip is used when certain information is to be displayed when a user hovers on a button.

Installation syntax:

ng add @angular/material


  • First, install the angular material using the above-mentioned command.
  • After completing the installation, Import ‘MatTooltipModule’ from ‘@angular/material/tooltip’ in the app.module.ts file.
  • We need to use ‘matTooltip’ property to display the text we want to render.
  • For showing the position we need to use the ‘matTooltipPosition’ property.
  • We can also customize the position of the tooltip regarding where to display like using the following names as “above”, “below”, “left”, “right” etc.
  • Once done with the above steps then serve or start the project.

Project Structure: It will look like the following.

Code Implementation:



import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { AppComponent } from './app.component'
import { BrowserAnimationsModule } from 
import { MatTooltipModule } from '@angular/material/tooltip'
import { MatButtonModule } from '@angular/material/button'
    imports: [ 
    declarations: [ AppComponent ], 
    bootstrap: [ AppComponent ] 
export class AppModule { }



<button mat-raised-button matTooltip=
    "Hover to display information on below."
    Hover to show information
<button mat-raised-button matTooltip=
    "Hover to display information on right."
    Hover to show information


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!