Bootstrap React Accordion

Build vertically collapsing accordions in combination with our Bootstrap React Collapse component.

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 #1
5 </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 each
9 element. These classes control the overall appearance, as well as the showing and
10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
11 our default variables. It's also worth noting that just about any HTML can go within
12 the <code>.accordion-body</code>, though the transition does limit overflow.
13 </CAccordionBody>
14 </CAccordionItem>
15 <CAccordionItem itemKey={2}>
16 <CAccordionHeader>
17 Accordion Item #2
18 </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 each
22 element. These classes control the overall appearance, as well as the showing and
23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
24 our default variables. It's also worth noting that just about any HTML can go within
25 the <code>.accordion-body</code>, though the transition does limit overflow.
26 </CAccordionBody>
27 </CAccordionItem>
28 <CAccordionItem itemKey={3}>
29 <CAccordionHeader>
30 Accordion Item #3
31 </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 each
35 element. These classes control the overall appearance, as well as the showing and
36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
37 our default variables. It's also worth noting that just about any HTML can go within
38 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 #1
5 </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 each
9 element. These classes control the overall appearance, as well as the showing and
10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
11 our default variables. It's also worth noting that just about any HTML can go within
12 the <code>.accordion-body</code>, though the transition does limit overflow.
13 </CAccordionBody>
14 </CAccordionItem>
15 <CAccordionItem itemKey={2}>
16 <CAccordionHeader>
17 Accordion Item #2
18 </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 each
22 element. These classes control the overall appearance, as well as the showing and
23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
24 our default variables. It's also worth noting that just about any HTML can go within
25 the <code>.accordion-body</code>, though the transition does limit overflow.
26 </CAccordionBody>
27 </CAccordionItem>
28 <CAccordionItem itemKey={3}>
29 <CAccordionHeader>
30 Accordion Item #3
31 </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 each
35 element. These classes control the overall appearance, as well as the showing and
36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
37 our default variables. It's also worth noting that just about any HTML can go within
38 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 #1
5 </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 each
9 element. These classes control the overall appearance, as well as the showing and
10 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
11 our default variables. It's also worth noting that just about any HTML can go within
12 the <code>.accordion-body</code>, though the transition does limit overflow.
13 </CAccordionBody>
14 </CAccordionItem>
15 <CAccordionItem itemKey={2}>
16 <CAccordionHeader>
17 Accordion Item #2
18 </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 each
22 element. These classes control the overall appearance, as well as the showing and
23 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
24 our default variables. It's also worth noting that just about any HTML can go within
25 the <code>.accordion-body</code>, though the transition does limit overflow.
26 </CAccordionBody>
27 </CAccordionItem>
28 <CAccordionItem itemKey={3}>
29 <CAccordionHeader>
30 Accordion Item #3
31 </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 each
35 element. These classes control the overall appearance, as well as the showing and
36 hiding via CSS transitions. You can modify any of this with custom CSS or overriding
37 our default variables. It's also worth noting that just about any HTML can go within
38 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// or
3import CAccordion from '@coreui/bootstrap-react/src/components/accordion/CAccordion'
PropertyDescriptionTypeDefault
activeItemKeyThe active item key.string | number-
alwaysOpenMake accordion items stay open when another item is openedbooleanfalse
classNameA string of all className you want applied to the base component.string-
flushRemoves 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// or
3import CAccordionBody from '@coreui/bootstrap-react/src/components/accordion/CAccordionBody'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-

CAccordionHeader#

1import { CAccordionHeader } from '@coreui/bootstrap-react'
2// or
3import CAccordionHeader from '@coreui/bootstrap-react/src/components/accordion/CAccordionHeader'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-

CAccordionItem#

1import { CAccordionItem } from '@coreui/bootstrap-react'
2// or
3import CAccordionItem from '@coreui/bootstrap-react/src/components/accordion/CAccordionItem'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-
itemKeyItem key.string | number-