Open In App

Angular PrimeNG Speed Dial Tooltip Component

Last Updated : 28 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the SpeedDial Tooltip Component in Angular PrimeNG. We will also learn about the properties, events & styling along with their syntaxes that will be used in the code.

The SpeedDial Component is used to display many primary actions that can be done using the floating button action while pressing the button.

Syntax:

<p-speedDial 
     [model]="..."
     radius="..."
     type="..."
     direction="..."
     buttonClassName="...">
</p-speedDial>

 

Angular PrimeNG Speed Dial Tooltip properties:

  • style: It is the inline style of the element. It is of object data type, the default value is null.
  • direction: It specifies the opening direction of actions. It is of string data type, the default value is up.
  • model: It is the MenuModel instance to define the action items. It is of object data type, the default value is null.
  • radius: It is the radius for *circle types, It is of number data type, and the default value is 0.
  • buttonClassName: It is the style class of the button element. It is of string data type, the default value is null.

Creating Angular application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

 

Steps to run the application: Run the below command to see the output:

ng serve --open

Example 1: Below is the example that illustrates the use of the Angular PrimeNG Speed Dial Tooltip.

  • app.component.html:

HTML




<div style="text-align: center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h5>Angular PrimeNG Speed Dial Tooltip Component</h5>
  
    <div style="height: 450px; 
        position: relative;" 
         class="speeddial-linear-demo">
        <p-speedDial [model]="gfg" 
                     direction="down"></p-speedDial>
    </div>
</div>


  • app.component.ts:

Javascript




import {Component, OnInit} from '@angular/core';
import { MenuItem, MessageService } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
    providers: [MessageService]
})
  
export class AppComponent { 
    gfg: MenuItem[];
  
    constructor(private messageService: MessageService) { }
  
    ngOnInit() {
        this.gfg = [
            {
               icon: 'pi pi-linkedin',
               tooltipOptions: {
                    tooltipLabel: "LinkedIn"
               },
            },
            {
               icon: 'pi pi-slack',
               tooltipOptions: {
                    tooltipLabel: "Slack"
               },
            },
            {
               icon: 'pi pi-whatsapp',
               tooltipOptions: {
                    tooltipLabel: "Whatsapp"
               },
            },
            {
               icon: 'pi pi-telegram',
               tooltipOptions: {
                    tooltipLabel: "Telegram"
               },
            },
            {
               icon: 'pi pi-twitter',
               tooltipOptions: {
                    tooltipLabel: "Twitter"
               },
            }
        ];
    }    
}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {RippleModule} from 'primeng/ripple';
import { ToastModule } from 'primeng/toast';
import { SpeedDialModule } from 'primeng/speeddial';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ProgressSpinnerModule,
        SpeedDialModule,
        ToastModule,
        RippleModule,
        RouterModule.forRoot([
           {path:'',component: AppComponent},
        ])
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: Below is another example that illustrates the use of the Angular PrimeNG Speed Dial Tooltip Component using type=”semi-circle”.

  • app.component.html:

HTML




<div style="text-align: center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h5>Angular PrimeNG Tooltip Component</h5>
  
    <div style="height: 500px; position: relative;" 
        class="speeddial-circle-demo">
        <p-speedDial
            [model]="gfg"
            radius="80"
            type="semi-circle"
            direction="down"
            buttonClassName="p-button-success">
        </p-speedDial>
    </div>
</div>


  • app.component.ts:

Javascript




import {Component, OnInit} from '@angular/core';
import { MenuItem, MessageService } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
    providers: [MessageService]
})
  
export class AppComponent { 
    gfg: MenuItem[];
  
    constructor(private messageService: MessageService) { }
  
    ngOnInit() {
        this.gfg = [
            {
               icon: 'pi pi-linkedin',
               tooltipOptions: {
                    tooltipLabel: "LinkedIn"
               },
            },
            {
               icon: 'pi pi-slack',
               tooltipOptions: {
                    tooltipLabel: "Slack"
               },
            },
            {
               icon: 'pi pi-whatsapp',
               tooltipOptions: {
                    tooltipLabel: "Whatsapp"
               },
            },
            {
               icon: 'pi pi-telegram',
               tooltipOptions: {
                    tooltipLabel: "Telegram"
               },
            },
            {
               icon: 'pi pi-twitter',
               tooltipOptions: {
                    tooltipLabel: "Twitter"
               },
            }
        ];
    }    
}


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {RippleModule} from 'primeng/ripple';
import { ToastModule } from 'primeng/toast';
import { SpeedDialModule } from 'primeng/speeddial';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ProgressSpinnerModule,
        SpeedDialModule,
        ToastModule,
        RippleModule,
        RouterModule.forRoot([
           {path:'',component: AppComponent},
        ])
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Reference: https://primefaces.org/primeng/speeddial



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads