English 中文(简体)
Angular Material 7 - Tooltip
  • 时间:2024-09-17

Angular Material 7 - Tooltip


Previous Page Next Page  

The <MatTooltip>, an Angular Directive, is used to show a material styled tooltip.

In this chapter, we will showcase the configuration required to show a tooltip using Angular Material.

Following is the content of the modified module descriptor app.module.ts.

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

Following is the content of the modified HTML host file app.component.html.

<button mat-raised-button
   matTooltip = "Sample Tooltip"
   aria-label = "Sample Tooltip">
   Cpck Me!
</button>

Result

Verify the result.

Tooltip

Details

    Here, we ve created a button using mat-button on hover, we ll show a tooltip.

Advertisements