Angular PrimeNG Accordion Default
Last Updated :
06 Oct, 2022
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 understanding the properties, & their syntaxes that will be used in the code.
The Accordion component is utilized to render the specific section of custom content in tabs. The element can contain more than one p-accordionTab element.
Syntax:
<p-accordion>
<p-accordionTab
header="..."
[selected]="true">
....
</p-accordionTab>
.......
</p-accordion>
Angular PrimeNG Accordion Default properties:
- header: It specifies the title of the tab. It is of string data type & the default value is null.
- selected: It defines if the tab is active. It is of the boolean data type & the default value is false.
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:
- Steps to run the application: Run the below command to see the output:
ng serve --open
Example 1: Below is the example that illustrates the use of the Angular PrimeNG Accordion Default.
app.component.html
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Accordion Default</h5>
<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>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent { }
app.module.ts
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: Below is another example that illustrates the use of the Angular PrimeNG Accordion Default.
app.component.html
<h2 style="color: green">GeeksforGeeks</h2>
<h5>Angular PrimeNG Accordion Default</h5>
<p-accordion>
<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-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-accordion>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent { }
app.module.ts
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:
Reference: https://primefaces.org/primeng/accordion
Similar Reads
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 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 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 Component 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 Component in Angular PrimeNG. We will also le
5 min read
Angular PrimeNG Accordion Lazy Loading 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 Lazy Loading in Angular PrimeNG. The Accordio
3 min read
Angular PrimeNG Accordion 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. In this article, we will see the Angular PrimeNG Accordion Styling. An Accordion Component is used t
3 min read
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 Tab Change Event 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 about the Angular PrimeNG Â Accordion Tab Change Event. The Accordion
3 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 TabView 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 know how to use the TabView Default in Angular PrimeNG. We will also learn
3 min read