Accordion
Build vertically collapsing accordions with an integrated JS module.
This component is still under development. Please only use the snippets provided below to avoid breaking changes.
View the official docs here
Examples
The following examples show how to implement the accordion with minimal code.
Basic Example
Fully Collapsed State
If you want your Accordion to start in a fully-collapsed state, then simply don’t add a show: true prop to any of the data elements.
Flush
Add flush to remove the default background-color, some borders, and some rounded corners to render accordions edge-to-edge with their parent container.
Always open
You can make accordion items stay open when another item is opened by using the alwaysOpen prop. If you’re looking to
control the component, you must use an array of strings for activeKey or defaultActiveKey.
Set ID and classes
The following properties are available:
idto add an id to the parentaccordiondiv.classto append a class to the parentaccordiondiv.itemClassto append a class to theaccordion-itemdiv.headerClassto append a class to theaccordion-headerdiv.bodyClassto append a class to theaccordion-bodydiv.
Manual Usage
No components
API
Accordion
import { Accordion } from 'astro-bootstrap' | Name | Type | Default | Description |
|---|---|---|---|
| data required | { header: string; body: string; show?: boolean;}[] | Data to display in accordion, including the show property. | |
| flush | boolean | false | Adds the 'accordion-flush' class to the accordion. |
| alwaysOpen | boolean | false | Prevents Accordion Items from closing when another one is opened |
| id | string | null | Set the id on the accordion div. |
| class | string | null | Appends a class to the accordion div. |
| itemClass | string | null | Appends a class to the accordion-item div. |
| headerClass | string | null | Appends a class to the accordion-header div. |
| bodyClass | string | null | Appends a class to the accordion-body div. |