Open In App

Angular PrimeNG Button Properties of pButton

Last Updated : 07 Nov, 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. This article will show us how to style the Tooltip component in Angular PrimeNG.

A Button is generally used for carrying out some action when clicked.  Buttons in the PrimeNG library come in different shapes, sizes, and many other properties. 

Properties of pButton:

  • label:  It is used to add the text of the button.
  • icon: It is used to add the name of the icon.
  • iconPos: It is used to indicate the position of the icon.
  • loading: It is used to indicate the loading state of the button.
  • loadingIcon: It is used to indicate the icon of the loading button.

Approach: Let us create an Angular project and install PrimeNG UI module. Then we will create a UI that will showcase Angular PrimeNG Button Properties of pButton.

Creating Angular Project and Installing module:

Step 1: To create an angular app, you need to install the angular command line interface through npm command.

npm install -g angular-cli

Step 2: Now we will create a angular project.

ng new project_name

Step 3: After creating your react project, move into the folder to perform different operations.

cd project_name

Step 4: After creating the Angular application, Install the required module using the following command:

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

Project Structure: After running the commands mentioned in the above steps, if you open the project in an editor, you can see a similar project structure as shown below. The new component user makes or the code changes, we will be performing will be done in the source folder.

Project Structure

Step to Run Application: Run the application using the following command from the root directory of the project:

ng serve --open

Example 1: We are creating a UI that shows above mentioned Properties of pButton.

  • app.component.html

HTML




<div style="margin:100px; text-align: center;">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
      
    <h3>
        Angular PrimeNG Button 
        Properties of pButton
    </h3><br />
      
    <p>Button with Label: </p>
    <button pButton type="button" label="Label"
        class="p-button-lg p-button-raised 
        p-button-text p-button-success">
    </button>
    <br /><br />
      
    <p> Icon Button:</p>
    <button pButton type="button" icon="pi pi-check"
        class="p-button-lg p-button-raised 
        p-button-rounded p-button-text p-button-success">
    </button>
      
    <p>Button with Label and Icon: </p>
    <button pButton type="button" 
        label="Sign Up" icon="pi pi-user"
        class="p-button-lg p-button-success ">
    </button><br /><br />
      
    <button pButton type="button" label="Log In" 
        icon="pi pi-check-circle" iconPos="right"
        class="p-button-lg p-button-success ">
    </button>
</div>


  • app.module.ts

Javascript




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: Now open your browser and go to http://localhost:3000/, you will see the following output:

Properties of pButton

Example 2: We are creating a UI that shows above mentioned Properties of pButton.

  • app.component.html

HTML




<div style="margin:100px; text-align: center;">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
      
    <h3>
        Angular PrimeNG Button 
        Properties of pButton
    </h3><br />
      
    <p>Button with Loading state: </p>
    <button pButton type="button" 
        label="Loading.." [loading]="true"
        class="p-button-lg p-button-raised 
        p-button-text p-button-success">
    </button>
    <br /><br />
      
    <button pButton type="button" label="Loading.." 
        [loading]="true" iconPos="right"
        class="p-button-lg p-button-raised 
        p-button-text p-button-success">
    </button>
    <br /><br />
      
    <p> Button with Loading state & Custom icon:</p>
    <button pButton type="button" 
        loadingIcon="pi pi-spin pi-sun" [loading]="true"
        class="p-button-lg p-button-rounded 
        p-button-success">
    </button>
</div>


  • app.module.ts

Javascript




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: Now open your browser and go to http://localhost:3000/, you will see the following output:

Properties of pButton

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



Previous Article
Next Article

Similar Reads

Angular PrimeNG Button Properties of p-button
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. This article will show us how to style the Tooltip component in Angular PrimeNG. A Button is generally used for carrying out some action when clicked.
5 min read
Angular PrimeNG Tree Properties
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. It provides a lot of templates, components, theme design, an extensive icon library, and much more. In this article, we are going to learn Angular Pri
6 min read
Angular PrimeNG Form TreeSelect Properties
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 the Angular PrimeNG Form TreeSelect Properties. The TreeSelect Component allows the users to select items from hierarch
7 min read
Angular PrimeNG Divider Properties
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 know how to use the Divider component properties in Angular PrimeNG. A divider Component is used to make a component that div
4 min read
Angular PrimeNG Table ColumnFilter Properties
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. It provides a lot of templates, components, theme design, an extensive icon library, and much more. In this article, we will see the Angular PrimeNG T
8 min read
Angular PrimeNG ProgressBar Properties
Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will see Angular PrimeNG ProgressBar Properties. ProgressBar Component is used to notify the user about the progress of a task. A progress bar can
3 min read
Angular PrimeNG ProgressSpinner Properties
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 ProgressSpinner Properties. ProgressSpinner Component is used to notify the user about the progress of
3 min read
Angular PrimeNG ConfirmPopup Properties
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 ConfirmPopup Properties in Angular PrimeNG. The ConfirmPopup Component is used to display a confirmation
5 min read
Angular PrimeNG TieredMenu Properties
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 TieredMenu Properties in Angular PrimeNG. We will also learn about the properties, along with their synt
4 min read
Angular PrimeNG Tooltip Properties
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 see how to use the Tooltip properties along with code examples in Angular PrimeNG. Tooltip component is used to make an eleme
5 min read