Open In App

Angular PrimeNG Panel Properties

Last Updated : 09 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. In this article, we will know the different properties of the Panel component in Angular PrimeNG. 

Panel Component allows us to make an element containing a header and some content associated with that header.

Panel Properties:

  • header: It is the header text of the panel. It is of string data type, the default value is null.
  • toggleable: It defines the content of the panel can be expanded and collapsed or not. It is of boolean data type, the default value is false.
  • collapsed: It defines the initial state of the panel content. It is of boolean data type, the default value is false.
  • style: It is an inline style of the component. It is of string data type, the default value is null.
  • styleClass: It is the style class of the component. It is of string data type, the default value is null.
  • expandIcon: It is the expand icon of the toggle button. It is of string data type, the default value is pi pi-plus.
  • collapseIcon: It is the collapsed icon of the toggle button. It is of string data type, the default value is pi pi-minus.
  • showHeader: It specifies if the header of a panel cannot be displayed. It is of boolean data type, and the default value is true.
  • transitionOptions: It is the transition option of the animation. It is of string data type, the default value is 400ms cubic-bezier(0.86, 0, 0.07, 1).
  • toggler: It specifies if the toggler element to toggle the panel content. It is of string data type, the default value is an icon.
  • iconPos: It is used to define the position of icons.

 

Creating Angular application & module installation:

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

npm install -g angular-cli

Step 2: Now we will create an angular project.

ng new project_name

Step 3: After creating your angular 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, it will look like the following:

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 Angular PrimeNG Panel Properties.

  • app.component.html:

HTML




<div style="margin:100px;">
    <h1 style="color: green;">GeeksforGeeks</h1>
    <h3>Angular PrimeNG Panel Properties</h3>
    <p-panel header="DSA Self Paced Course" 
        [toggleable]="true" [collapsed]="true" 
        collapseIcon="pi pi-angle-double-up"
        expandIcon="pi pi-angle-double-down">
        <p>
            Most popular course on DSA trusted by 
            over 75,000 students! Built with years 
            of experience by industry experts and 
            gives you a complete package of video 
            lectures, practice problems, quizzes, 
            discussion forums and contests. Start 
            Today!
        </p>
    </p-panel>
</div>


  • app.module.ts:

Javascript




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


Output:

 

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

  • app.component.html

HTML




<div style="margin:100px;">
    <h1 style="color: green;">GeeksforGeeks</h1>
    <h3>Angular PrimeNG Panel Properties</h3>
    <p-panel header="Hi Geek!" [toggleable]="true" 
        [collapsed]="true" collapseIcon="pi pi-angle-double-up"
        expandIcon="pi pi-angle-double-down" iconPos="center">
        <p>
            Welcome to Geeks For Geeks!<br />Billions of Users, 
            Millions of Articles Published, Thousands Got Hired 
            by Top Companies and the numbers are still growing.
        </p>
    </p-panel>
</div>


  • app.module.ts:

Javascript




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


Output:

 

Reference: https://primefaces.org/primeng/panel



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads