Open In App

Angular PrimeNG Speed Dial Direction

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 Direction 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]="..."
    type="..."
    direction="..."
    showIcon="..."
    hideIcon="..."
    radius="..."
    buttonClassName="..." >
</p-speedDial>

 



Angular PrimeNG Speed Dial Direction properties:

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 Direction Component using linear and semi-circle type




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Speed Dial Direction</h5>
  
<div style="height: 400px; position: relative;" 
    class="speeddial-linear-demo">
    <p-speedDial
        [model]="gfg"
        showIcon="pi pi-arrow-up-right"
        hideIcon="pi pi-times"
        direction="up">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        showIcon="pi pi-arrow-up-right"
        hideIcon="pi pi-times"
        direction="down">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        showIcon="pi pi-arrow-up-right"
        hideIcon="pi pi-times"
        direction="left"
        type="semi-circle">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        showIcon="pi pi-arrow-up-right"
        hideIcon="pi pi-times"
        direction="right"
        type="semi-circle">
    </p-speedDial>
</div>




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-twitter',
            },
        ];
    }
}




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 Direction Component using type=”quarter-circle”.




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Speed Dial Direction</h5>
  
<div style="width: 300px; height: 300px; position: relative;" 
    class="speeddial-circle-demo">
    <p-speedDial
        [model]="gfg"
        radius="120"
        direction="up-left"
        type="quarter-circle"
        buttonClassName="p-button-success">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        radius="120"
        direction="up-right"
        type="quarter-circle"
        buttonClassName="p-button-success">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        radius="120"
        direction="down-left"
        type="quarter-circle"
        buttonClassName="p-button-success">
    </p-speedDial>
  
    <p-speedDial
        [model]="gfg"
        radius="120"
        direction="down-right"
        type="quarter-circle"
        buttonClassName="p-button-success">
    </p-speedDial>
</div>




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-twitter',
            },
        ];
    }
}




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


Article Tags :