Bootstrap React Accordion
Build vertically collapsing accordions in combination with our Bootstrap React Collapse component.
On this page
Examples#
Click the accordions below to expand/collapse the accordion content.
This is the first item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.1<CAccordion activeItemKey={2}>2 <CAccordionItem itemKey={1}>3 <CAccordionHeader>4 Accordion Item #15 </CAccordionHeader>6 <CAccordionBody>7 <strong>This is the first item's accordion body.</strong> It is hidden by default,8 until the collapse plugin adds the appropriate classes that we use to style each9 element. These classes control the overall appearance, as well as the showing and10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding11 our default variables. It's also worth noting that just about any HTML can go within12 the <code>.accordion-body</code>, though the transition does limit overflow.13 </CAccordionBody>14 </CAccordionItem>15 <CAccordionItem itemKey={2}>16 <CAccordionHeader>17 Accordion Item #218 </CAccordionHeader>19 <CAccordionBody>20 <strong>This is the second item's accordion body.</strong> It is hidden by default,21 until the collapse plugin adds the appropriate classes that we use to style each22 element. These classes control the overall appearance, as well as the showing and23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding24 our default variables. It's also worth noting that just about any HTML can go within25 the <code>.accordion-body</code>, though the transition does limit overflow.26 </CAccordionBody>27 </CAccordionItem>28 <CAccordionItem itemKey={3}>29 <CAccordionHeader>30 Accordion Item #331 </CAccordionHeader>32 <CAccordionBody>33 <strong>This is the second item's accordion body.</strong> It is hidden by default,34 until the collapse plugin adds the appropriate classes that we use to style each35 element. These classes control the overall appearance, as well as the showing and36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding37 our default variables. It's also worth noting that just about any HTML can go within38 the <code>.accordion-body</code>, though the transition does limit overflow.39 </CAccordionBody>40 </CAccordionItem>41</CAccordion>
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.
This is the first item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.1<CAccordion flush>2 <CAccordionItem itemKey={1}>3 <CAccordionHeader>4 Accordion Item #15 </CAccordionHeader>6 <CAccordionBody>7 <strong>This is the first item's accordion body.</strong> It is hidden by default,8 until the collapse plugin adds the appropriate classes that we use to style each9 element. These classes control the overall appearance, as well as the showing and10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding11 our default variables. It's also worth noting that just about any HTML can go within12 the <code>.accordion-body</code>, though the transition does limit overflow.13 </CAccordionBody>14 </CAccordionItem>15 <CAccordionItem itemKey={2}>16 <CAccordionHeader>17 Accordion Item #218 </CAccordionHeader>19 <CAccordionBody>20 <strong>This is the second item's accordion body.</strong> It is hidden by default,21 until the collapse plugin adds the appropriate classes that we use to style each22 element. These classes control the overall appearance, as well as the showing and23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding24 our default variables. It's also worth noting that just about any HTML can go within25 the <code>.accordion-body</code>, though the transition does limit overflow.26 </CAccordionBody>27 </CAccordionItem>28 <CAccordionItem itemKey={3}>29 <CAccordionHeader>30 Accordion Item #331 </CAccordionHeader>32 <CAccordionBody>33 <strong>This is the third item's accordion body.</strong> It is hidden by default,34 until the collapse plugin adds the appropriate classes that we use to style each35 element. These classes control the overall appearance, as well as the showing and36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding37 our default variables. It's also worth noting that just about any HTML can go within38 the <code>.accordion-body</code>, though the transition does limit overflow.39 </CAccordionBody>40 </CAccordionItem>41</CAccordion>
Always open#
Add alwaysOpen
property to make accordion items stay open when another item is opened.
This is the first item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the
.accordion-body
, though the transition does limit overflow.1<CAccordion alwaysOpen activeItemKey={2}>2 <CAccordionItem itemKey={1}>3 <CAccordionHeader>4 Accordion Item #15 </CAccordionHeader>6 <CAccordionBody>7 <strong>This is the first item's accordion body.</strong> It is hidden by default,8 until the collapse plugin adds the appropriate classes that we use to style each9 element. These classes control the overall appearance, as well as the showing and10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding11 our default variables. It's also worth noting that just about any HTML can go within12 the <code>.accordion-body</code>, though the transition does limit overflow.13 </CAccordionBody>14 </CAccordionItem>15 <CAccordionItem itemKey={2}>16 <CAccordionHeader>17 Accordion Item #218 </CAccordionHeader>19 <CAccordionBody>20 <strong>This is the second item's accordion body.</strong> It is hidden by default,21 until the collapse plugin adds the appropriate classes that we use to style each22 element. These classes control the overall appearance, as well as the showing and23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding24 our default variables. It's also worth noting that just about any HTML can go within25 the <code>.accordion-body</code>, though the transition does limit overflow.26 </CAccordionBody>27 </CAccordionItem>28 <CAccordionItem itemKey={3}>29 <CAccordionHeader>30 Accordion Item #331 </CAccordionHeader>32 <CAccordionBody>33 <strong>This is the second item's accordion body.</strong> It is hidden by default,34 until the collapse plugin adds the appropriate classes that we use to style each35 element. These classes control the overall appearance, as well as the showing and36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding37 our default variables. It's also worth noting that just about any HTML can go within38 the <code>.accordion-body</code>, though the transition does limit overflow.39 </CAccordionBody>40 </CAccordionItem>41</CAccordion>
API#
CAccordion#
1import { CAccordion } from '@coreui/bootstrap-react'2// or3import CAccordion from '@coreui/bootstrap-react/src/components/accordion/CAccordion'
Property | Description | Type | Default |
---|---|---|---|
activeItemKey | The active item key. | string | number | - |
alwaysOpen | Make accordion items stay open when another item is opened | boolean | false |
className | A string of all className you want applied to the base component. | string | - |
flush | Removes the default background-color, some borders, and some rounded corners to render accordions edge-to-edge with their parent container. | boolean | - |
CAccordionBody#
1import { CAccordionBody } from '@coreui/bootstrap-react'2// or3import CAccordionBody from '@coreui/bootstrap-react/src/components/accordion/CAccordionBody'
Property | Description | Type | Default |
---|---|---|---|
className | A string of all className you want applied to the base component. | string | - |
CAccordionHeader#
1import { CAccordionHeader } from '@coreui/bootstrap-react'2// or3import CAccordionHeader from '@coreui/bootstrap-react/src/components/accordion/CAccordionHeader'
Property | Description | Type | Default |
---|---|---|---|
className | A string of all className you want applied to the base component. | string | - |
CAccordionItem#
1import { CAccordionItem } from '@coreui/bootstrap-react'2// or3import CAccordionItem from '@coreui/bootstrap-react/src/components/accordion/CAccordionItem'
Property | Description | Type | Default |
---|---|---|---|
className | A string of all className you want applied to the base component. | string | - |
itemKey | Item key. | string | number | - |