Angular PrimeNG Accordion Styling
Last Updated :
28 Apr, 2025
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 the Angular PrimeNG Accordion Styling.
An Accordion Component is used to display a section of custom content in tabs.
Angular PrimeNG Accordion Styling:
- p-accordion: it is the container element.
- p-accordion-header: it is the header of a tab.
- p-accordion-content: it is the content of a tab.
Syntax
<p-accordion>
<p-accordionTab header="Header">
Content
</p-accordionTab>
</p-accordion>
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:

Example 1: This example illustrates the use of the Angular PrimeNG Accordion Styling, where the first accordion is initially selected. Here, we have implemented the p-accordion and p-accordion-content.
HTML
<h1 style="color: green">
GeeksforGeeks
</h1>
<h3>
Angular PrimeNG Accordion Styling
</h3>
<p-accordion>
<p-accordionTab header="Angular PrimeNG"
[selected]="true">
<p>
Angular PrimeNG is a framework used
with angular to create components with
great styling and this framework is very
easy to use and is used to make responsive
websites.
</p>
</p-accordionTab>
<p-accordionTab header="Angular PrimeNG">
<p>
Angular PrimeNG is a framework used
with angular to create components with
great styling and this framework is very
easy to use and is used to make responsive
websites.
</p>
</p-accordionTab>
<p-accordionTab header="Angular PrimeNG">
<p>
Angular PrimeNG is a framework used
with angular to create components with
great styling and this framework is very
easy to use and is used to make responsive
websites.
</p>
</p-accordionTab>
</p-accordion>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent { }
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 { AccordionModule } from "primeng/accordion";
@NgModule({
imports: [BrowserModule,
BrowserAnimationsModule,
AccordionModule],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
Output

Example 2: This is another example that illustrates the use of the Angular PrimeNG Accordion Styling by implementing the p-accordion-header.
HTML
<div style="width: 400px;">
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3>
Angular PrimeNG Accordion Styling
</h3>
<div class="mb-4">
<button pButton type="button"
class="mr-3"
label="Toggle Tab 1"
(click)="toggleTab(0)">
</button>
<button pButton type="button"
label="Toggle Tab 2"
(click)="toggleTab(1)">
</button>
</div>
<p-accordion [multiple]="true">
<p-accordionTab header="AccordionTab 1 Header"
[(selected)]="activeTabs[0]">
This is the content of the Accordion Tab 1.
</p-accordionTab>
<p-accordionTab header="AccordionTab 2 Header"
[(selected)]="activeTabs[1]">
This is the content of the Accordion Tab 2.
</p-accordionTab>
</p-accordion>
</div>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
activeTabs: boolean[] = [false, false];
toggleTab(idx: number) {
this.activeTabs[idx] =
!this.activeTabs[idx];
}
}
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule }
from "@angular/platform-browser";
import { HttpClientModule }
from "@angular/common/http";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
import { AccordionModule } from "primeng/accordion";
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
ButtonModule,
AccordionModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
Output:
Reference: http://primefaces.org/primeng/accordion
Similar Reads
Angular PrimeNG Accordion Selected 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 Accordion Selected in Angular PrimeNG, along with unders
4 min read
Angular PrimeNG Accordion Templates Angular PrimeNG is a UI component library built by PrimeTek to help out Angular developers for easing the process of developing consistent and scalable web interfaces in less time. In this article, we will talk about Accordion Templates in Angular PrimeNG. The Accordion Component displays the conten
3 min read
Angular PrimeNG Accordion Programmatic 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 Accordion Programmatic in Angular PrimeNG. We will also
4 min read
Angular PrimeNG Accordion Events 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 Events of Accordion component in Angular PrimeNG. Accordion component
3 min read
Angular PrimeNG Accordion Default 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 Accordion Default in Angular PrimeNG, along with underst
4 min read
Angular PrimeNG Accordion Multiple 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 Accordion Multiple in Angular PrimeNG, along with unders
3 min read
Angular PrimeNG Accordion Disabled 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 Accordion Disabled in Angular PrimeNG, along with unders
3 min read
Angular PrimeNG Dock Styling 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.
4 min read
Angular PrimeNG Menu Styling A responsive website may be easily created using the open-source Angular PrimeNG framework, which has a wide range of native Angular UI components for superb style. In this article, we will learn how to style the Menu Component in Angular PrimeNG. A component that holds information and allows both s
4 min read
Angular PrimeNG Tree Styling 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.
5 min read