Open In App

Angular ngx Bootstrap Accordion Component

Last Updated : 06 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Angular ngx bootstrap is a bootstrap 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.

In this article, we will know how to use accordion in angular ngx bootstrap. The Accordion is used to display collapsible content that presents information in a limited amount of space.

Installation syntax:

npm install ngx-bootstrap --save 

 

Approach:

  • First, install the angular ngx bootstrap using the above-mentioned command.
  •  

  • Add the following script in index.html

    <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css” rel=”stylesheet”>

  • Import accordion component in module.ts
  • In app.component.html make an accordion component.
  • Serve the app using ng serve.

Example 1:

index.html




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <base href="/">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1">
    <link href=
        rel="stylesheet">
  
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href=
        rel="stylesheet">
        rel="stylesheet">
</head>
  
<body class="mat-typography">
    <app-root></app-root>
</body>
  
</html>


app.component.html




<accordion [isAnimated]="true">
    <accordion-group heading="Header1">
        <p>content1</p>
    </accordion-group>
  
    <accordion-group heading="Header2">
        <p>content2</p>
    </accordion-group>
  
    <accordion-group heading="Header3">
        <p>content3</p>
    </accordion-group>
  
    <accordion-group heading="Header4">
        <p>content4</p>
    </accordion-group>
</accordion>


app.module.ts




import { NgModule } from '@angular/core';
  
// Importing forms module
import { FormsModule, ReactiveFormsModule }
    from '@angular/forms';
import { BrowserModule }
    from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { AccordionModule }
    from 'ngx-bootstrap/accordion';
  
import { AppComponent }
    from './app.component';
  
@NgModule({
    bootstrap: [
        AppComponent
    ],
    declarations: [
        AppComponent
    ],
    imports: [
        FormsModule,
        BrowserModule,
        BrowserAnimationsModule,
        ReactiveFormsModule,
        AccordionModule.forRoot()
    ]
})
export class AppModule { }


Output:

Reference: https://valor-software.com/ngx-bootstrap/#/accordion



Similar Reads

Angular ngx Bootstrap Collapse Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will learn how to use collapse in angular ngx bootstrap. Collapse is used to make a button that will collapse by clicking on it. Installation syn
2 min read
Angular ngx Bootstrap Alerts Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use alert in angular ngx bootstrap. The Alerts is used to provide contextual feedback messages for typical user actions with the
2 min read
Angular ngx Bootstrap Buttons Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will see how to use buttons in angular ngx bootstrap. Buttons are used to make a group of buttons. Installation syntax: npm install ngx-bootstrap
2 min read
Angular ngx Bootstrap Typeahead Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use Typeahead in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angul
2 min read
Angular ngx Bootstrap Tabs Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use Tabs in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angular ng
2 min read
Angular ngx Bootstrap Timepicker Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use Timepicker in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angu
2 min read
Angular ngx Bootstrap Tooltip Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will see how to use Tooltip in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angular
2 min read
Angular ngx bootstrap Pagination Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use Pagination in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angu
2 min read
Angular ngx bootstrap Dropdowns Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will see how to use Dropdowns in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angula
2 min read
Angular ngx Bootstrap Rating Component
Angular ngx bootstrap is a bootstrap 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. In this article, we will know how to use Rating in angular ngx bootstrap. Rating is used to make a component that will be shown by using stars. Installation syntax:
2 min read