Tooltip for button in Angular Button component

15 Sep 20221 minute to read

Tooltip can be shown on button hover and it can be achieved by setting title attribute.

The following snippets illustrates how to show tooltip on button hover.

import { Component, ViewChild, OnInit } from '@angular/core';
import { ButtonComponent } from '@syncfusion/ej2-angular-buttons';

@Component({
    selector: 'app-root',
    styleUrls:['styles.css'],
    template:  `<button #btn ejs-button [isPrimary]="true">Button</button>`
})

export class AppComponent implements OnInit {
  @ViewChild('btn')
  private btn: ButtonComponent;
  ngOnInit() {
    this.btn.element.setAttribute("title", "Primary Button")
  }
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { AppComponent } from './app.component';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
        ButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);