How to use matTooltip in Angular Material ?
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.
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.