Open In App

Angular PrimeNG Button Rounded Buttons Component

Improve
Improve
Like Article
Like
Save
Share
Report

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 Rounded Buttons Component.

A Button component is used for carrying out some action when clicked. A rounded button has its corners rounded. The p-button-rounded class can be used to make a button rounded.

Angular PrimeNG Button Rounded Buttons Component Properties:

  • label: This property of the button component is used to set the text of the button.
  • icon: The icon property of the button is used to set the icon to display in the button.

Angular PrimeNG Button Rounded Buttons Component Styling:

  • p-button-rounded: This class is used to make a button rounded.

Syntax:

<button pButton type="button" 
      label="..." 
      class="p-button-rounded">
</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: In this example, we used the p-button-rounded class to create a rounded button.

app.component.html




<div class="header">
    <h2>GeeksforGeeks</h2>
    <h3>
      Angular PrimeNG Button 
      Rounded Buttons Component
    </h3>
</div>
  
<div class="buttons">
    <button pButton 
        type="button" 
        label="Rounded Button" 
        class="p-button-rounded">
    </button>
  
    <button pButton 
        type="button" 
        label="Rounded Text Button" 
        class="p-button-text p-button-rounded">
    </button>
</div>


app.component.css




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


app.component.ts




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


app.module.ts




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: In this example, we used the icon property of the button to set the icon for the rounded button.

app.component.html




<div class="header">
    <h2>GeeksforGeeks</h2>
    <h3>
      Angular PrimeNG Button 
      Rounded Buttons Component
    </h3>
</div>
  
<div class="buttons">
    <button pButton 
        type="button"
        icon="pi pi-hashtag" 
        label="Rounded Button with Icon" 
        class="p-button-rounded">
    </button>
  
    <button pButton 
        type="button"
        icon="pi pi-circle" 
        label="Rounded Button with Icon" 
        class="p-button-rounded">
    </button>
</div>


app.component.css




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


app.component.ts




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


app.module.ts




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



Last Updated : 12 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads