Implementation
To begin, add the MatTooltipModule to the app. Go to the app module file, add the import statement, and add it to the app.
import { MatTooltipModule } from '@angular/material/tooltip';
Adding the Tooltip
Go to an HTML page and locate the element that you want to apply the tooltip to.
If your tooltip requires you to change based on certain events, you should use a variable instead. Wrap the tooltip directive in brackets. Then replace the string value with the variable.
Repositioning the tooltip
To reposition the tooltip, apply the matTooltipPosition input and set it to either above, below, left, or right.
Changing the duration
Toggling the Tooltip Manually
<button (click)="tempRef.toggle()">Toggle</button>
Instead of using a single button to toggle the tooltip, we can divide the task into 2 separate actions.
<button (click)="tempRef.show()">Show</button>
<button (click)="tempRef.hide()">Hide</button>
The show() function will make the tooltip appear and the hide() function will make it disappear.