Open In App

Angular PrimeNG Speed Dial Linear

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 Linear Component in Angular PrimeNG. We will also learn about the properties, 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]="..." 
    direction="...">
</p-speedDial>

 

Angular PrimeNG Speed Dial Linear 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.

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 Linear using up and down direction values.

  • app.component.html:

HTML




<div style="text-align: center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h5>Angular PrimeNG Speed Dial Linear</h5>
  
    <div style="height: 450px; 
        position: relative;" 
         class="speeddial-linear-demo">
        <p-speedDial [model]="gfg" 
                     direction="up"></p-speedDial>
        <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',
            },
            {
                icon: 'pi pi-slack',
            },
            {
                icon: 'pi pi-whatsapp',
            },
            {
                icon: 'pi pi-telegram',
            },
            {
                icon: 'pi pi-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 Linear using left and right direction values.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Speed Dial Linear</h5>
  
<div style="height: 100px; width: 500px; position: relative;"
    class="speeddial-linear-demo">
    <p-speedDial [model]="gfg" direction="left"></p-speedDial>
    <p-speedDial [model]="gfg" direction="right"></p-speedDial>
</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',
            },
            {
                icon: 'pi pi-slack',
            },
            {
                icon: 'pi pi-whatsapp',
            },
            {
                icon: 'pi pi-telegram',
            },
            {
                icon: 'pi pi-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