Accordion
Angular Bootstrap 5 Accordion component
Responsive Accordion built with Bootstrap 5, Angular and Material Design. Accordion is a vertically collapsing element to show and hide content via class changes.
Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.
How it works
The accordion uses collapse internally to
make it collapsible. To render an accordion that’s expanded, use
[collapsed]="false"
on accordion item.
Basic example
Click the accordions below to expand/collapse the accordion content.
Flush
Use [flush]="true"
input to remove the default background-color
,
some borders, and some rounded corners to render accordions edge-to-edge with their parent
container.
Borderless
Use [borderless]="true"
input to remove all the borders and add a background color to the active item.
.accordion-borderless
class. This is the first item's accordion body.
.accordion-borderless
class. This is the second item's accordion body.
Let's imagine this being filled with some actual content.
.accordion-borderless
class. This is the third item's accordion body.
Nothing more exciting happening here in terms of content, but just filling up
the space to make it look, at least at first glance, a bit more representative
of how this would look in a real-world application.
Always open
Use [multiple]="true"
input to make accordion items stay open when another item
is opened.
Disabled item
Add [disabled]="true"
input to accordion items you want to disable
Accessibility
Please read the collapse accessibility section for more information.
Accordion - API
Import
Inputs
MdbAccordionComponent
Name | Type | Default | Description |
---|---|---|---|
borderless |
Boolean | false |
Removes all the borders and adds a background-color to the active item
items
|
flush |
Boolean | false |
Removes background-color and border styles from accordion
items
|
multiple |
Boolean | false |
Whether multiple opened accordion items should be allowed |
MdbAccordionItemComponent
Name | Type | Default | Description |
---|---|---|---|
disabled |
Boolean | false |
Enables/disables accordion item |
collapsed |
Boolean | true |
Whether item should be collapsed by default |
header |
String |
|
Defines string that will be displayed as item header |
Outputs
MdbAccordionItemComponent
Name | Type | Description |
---|---|---|
itemShow |
EventEmitter<MdbAccordionItemComponent> | Fires when show animation starts. |
itemShown |
EventEmitter<MdbAccordionItemComponent> | Fires when show animation ends. |
itemHide |
EventEmitter<MdbAccordionItemComponent> | Fires when hide animation starts. |
itemHidden |
EventEmitter<MdbAccordionItemComponent> | Fires when hide animation ends. |
Methods
MdbAccordionItemComponent
Name | Description | Example |
---|---|---|
hide |
Hides the accordion item |
accordionItem.hide()
|
show |
Shows the accordion item |
accordionItem.show()
|
toggle |
Manually toggles the accordion item |
accordionItem.toggle()
|
CSS variables
As part of MDB’s evolving CSS variables approach, accordion now uses local CSS variables on
.accordion
for enhanced real-time customization. Values for the CSS variables
are set via Sass, so Sass customization is still supported, too.