Open In App

Angular PrimeNG Button Severity Component

Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG Button Severity Component.

A Button component is used for carrying out some action when clicked. In PrimeNG, different colored buttons are available for different severity levels. There are a total of 6 severity levels: Primary (default), Secondary, Success, Info, Warning, Help, and Danger.

Angular PrimeNG Button Severity Component Properties:



Angular PrimeNG Button Severity Component Styling:

Syntax:



<button pButton 
    type="button" 
    label="..." 
    class="...">
</button>

Creating Angular Application and Installing the Module:

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: Finally, Install PrimeNG in your given directory.

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

The project Structure will look like this after following the above steps:

Project Structure

Run the below command to see the output.

ng serve --open

Example 1: This example shows the use of the Secondary, Success, and info severity buttons.




<div class="header">
    <h2>GeeksforGeeks</h2>
    <h3>
      Angular PrimeNG Button 
      Severity Component
    </h3>
</div>
  
<div class="buttons">
    <button pButton type="button" 
          label="Primary (Default) Button">
    </button>
  
    <button pButton type="button" 
        label="Secondary Button" 
        class="p-button-secondary">
    </button>
  
    <button pButton type="button" 
        label="Success Button" 
        class="p-button-success">
    </button>
  
    <button pButton type="button" 
        label="Info Button" class="p-button-info">
    </button>
</div>




div{
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
  
.header h2{
    margin-bottom: 0;
    color: green;
}
  
button{
    margin-bottom: 10px;
}




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
  
export class AppComponent {}




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import {ButtonModule} from 'primeng/button'
  
@NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      ButtonModule,
    ],
    providers: [],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Example 2: This example illustrates the use of the warning, help, and danger severity buttons.




<div class="header">
    <h2>GeeksforGeeks</h2>
    <h3>
      Angular PrimeNG Button 
      Severity Component
    </h3>
</div>
  
<div class="buttons">
    <button pButton type="button" 
        label="Primary (Default) Button">
    </button>
  
    <button pButton type="button" 
        label="Warning Button" 
        class="p-button-warning">
    </button>
  
    <button pButton type="button" 
        label="Help Button" class="p-button-help">
    </button>
  
    <button pButton type="button" 
        label="Danger Button" class="p-button-danger">
    </button>
</div>




div{
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
  
.header h2{
    margin-bottom: 0;
    color: green;
}
  
button{
    margin-bottom: 10px;
}




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
  
export class AppComponent {}




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import {ButtonModule} from 'primeng/button'
  
@NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      ButtonModule,
    ],
    providers: [],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Reference: http://primefaces.org/primeng/button


Article Tags :