@@ -8,138 +8,35 @@ other_frameworks: accordion
8
8
pro_component : false
9
9
---
10
10
11
- import { useState } from ' react'
12
-
13
- import {
14
- CAccordion ,
15
- CAccordionBody ,
16
- CAccordionCollapse ,
17
- CAccordionHeader ,
18
- CAccordionItem ,
19
- } from ' @coreui/react/src/index'
20
-
21
11
## How to use React Accordion component.
22
12
23
13
Click the accordions below to expand/collapse the accordion content.
24
14
25
- ``` jsx preview
26
- < CAccordion activeItemKey= {2 }>
27
- < CAccordionItem itemKey= {1 }>
28
- < CAccordionHeader> Accordion Item #1 < / CAccordionHeader>
29
- < CAccordionBody>
30
- < strong> This is the first item' s accordion body.</strong> It is hidden by default, until the
31
- collapse plugin adds the appropriate classes that we use to style each element. These classes
32
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
33
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
34
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
35
- does limit overflow.
36
- < / CAccordionBody>
37
- < / CAccordionItem>
38
- < CAccordionItem itemKey= {2 }>
39
- < CAccordionHeader> Accordion Item #2 < / CAccordionHeader>
40
- < CAccordionBody>
41
- < strong> This is the second item' s accordion body.</strong> It is hidden by default, until the
42
- collapse plugin adds the appropriate classes that we use to style each element. These classes
43
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
44
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
45
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
46
- does limit overflow.
47
- < / CAccordionBody>
48
- < / CAccordionItem>
49
- < CAccordionItem itemKey= {3 }>
50
- < CAccordionHeader> Accordion Item #3 < / CAccordionHeader>
51
- < CAccordionBody>
52
- < strong> This is the second item' s accordion body.</strong> It is hidden by default, until the
53
- collapse plugin adds the appropriate classes that we use to style each element. These classes
54
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
55
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
56
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
57
- does limit overflow.
58
- < / CAccordionBody>
59
- < / CAccordionItem>
60
- < / CAccordion>
61
- ```
15
+ import { AccordionExample } from ' ./examples/AccordionExample.tsx'
16
+ import AccordionExampleTS from ' !!raw-loader!./examples/AccordionExample.tsx'
17
+
18
+ <ExampleSnippet code = { AccordionExampleTS } componentName = " React Accordion" >
19
+ <AccordionExample />
20
+ </ExampleSnippet >
62
21
63
22
### Flush
64
23
65
24
Add ` flush ` to remove the default ` background-color ` , some borders, and some rounded corners to render accordions edge-to-edge with their parent container.
66
25
67
- ``` jsx preview
68
- < CAccordion flush>
69
- < CAccordionItem itemKey= {1 }>
70
- < CAccordionHeader> Accordion Item #1 < / CAccordionHeader>
71
- < CAccordionBody>
72
- < strong> This is the first item' s accordion body.</strong> It is hidden by default, until the
73
- collapse plugin adds the appropriate classes that we use to style each element. These classes
74
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
75
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
76
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
77
- does limit overflow.
78
- < / CAccordionBody>
79
- < / CAccordionItem>
80
- < CAccordionItem itemKey= {2 }>
81
- < CAccordionHeader> Accordion Item #2 < / CAccordionHeader>
82
- < CAccordionBody>
83
- < strong> This is the second item' s accordion body.</strong> It is hidden by default, until the
84
- collapse plugin adds the appropriate classes that we use to style each element. These classes
85
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
86
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
87
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
88
- does limit overflow.
89
- < / CAccordionBody>
90
- < / CAccordionItem>
91
- < CAccordionItem itemKey= {3 }>
92
- < CAccordionHeader> Accordion Item #3 < / CAccordionHeader>
93
- < CAccordionBody>
94
- < strong> This is the third item' s accordion body.</strong> It is hidden by default, until the
95
- collapse plugin adds the appropriate classes that we use to style each element. These classes
96
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
97
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
98
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
99
- does limit overflow.
100
- < / CAccordionBody>
101
- < / CAccordionItem>
102
- < / CAccordion>
103
- ```
26
+ import { AccordionFlushExample } from ' ./examples/AccordionFlushExample.tsx'
27
+ import AccordionFlushExampleTS from ' !!raw-loader!./examples/AccordionFlushExample.tsx'
28
+
29
+ <ExampleSnippet code = { AccordionFlushExampleTS } componentName = " React Accordion" >
30
+ <AccordionFlushExample />
31
+ </ExampleSnippet >
104
32
105
33
### Always open
106
34
107
35
Add ` alwaysOpen ` property to make react accordion items stay open when another item is opened.
108
36
109
- ``` jsx preview
110
- < CAccordion alwaysOpen activeItemKey= {2 }>
111
- < CAccordionItem itemKey= {1 }>
112
- < CAccordionHeader> Accordion Item #1 < / CAccordionHeader>
113
- < CAccordionBody>
114
- < strong> This is the first item' s accordion body.</strong> It is hidden by default, until the
115
- collapse plugin adds the appropriate classes that we use to style each element. These classes
116
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
117
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
118
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
119
- does limit overflow.
120
- < / CAccordionBody>
121
- < / CAccordionItem>
122
- < CAccordionItem itemKey= {2 }>
123
- < CAccordionHeader> Accordion Item #2 < / CAccordionHeader>
124
- < CAccordionBody>
125
- < strong> This is the second item' s accordion body.</strong> It is hidden by default, until the
126
- collapse plugin adds the appropriate classes that we use to style each element. These classes
127
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
128
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
129
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
130
- does limit overflow.
131
- < / CAccordionBody>
132
- < / CAccordionItem>
133
- < CAccordionItem itemKey= {3 }>
134
- < CAccordionHeader> Accordion Item #3 < / CAccordionHeader>
135
- < CAccordionBody>
136
- < strong> This is the second item' s accordion body.</strong> It is hidden by default, until the
137
- collapse plugin adds the appropriate classes that we use to style each element. These classes
138
- control the overall appearance, as well as the showing and hiding via CSS transitions. You can
139
- modify any of this with custom CSS or overriding our default variables. It' s also worth noting
140
- that just about any HTML can go within the < code> .accordion - body< / code> , though the transition
141
- does limit overflow.
142
- < / CAccordionBody>
143
- < / CAccordionItem>
144
- < / CAccordion>
145
- ```
37
+ import { AccordionAlwaysOpenExample } from ' ./examples/AccordionAlwaysOpenExample.tsx'
38
+ import AccordionAlwaysOpenExampleTS from ' !!raw-loader!./examples/AccordionAlwaysOpenExample.tsx'
39
+
40
+ <ExampleSnippet code = { AccordionAlwaysOpenExampleTS } componentName = " React Accordion" >
41
+ <AccordionAlwaysOpenExample />
42
+ </ExampleSnippet >
0 commit comments