Debian Codegraph @

node/@patternfly/patternfly/docs/components/ExpandableSection/examples/ExpandableSection.md

raw
1 ---
2 id: Expandable section
3 section: components
4 cssPrefix: pf-v6-c-expandable-section
5 ---## Examples
6
7 ### Hidden
8
9 ```html
10 <div class="pf-v6-c-expandable-section">
11 <div class="pf-v6-c-expandable-section__toggle">
12 <button
13 class="pf-v6-c-button pf-m-link"
14 id="hidden-toggle"
15 type="button"
16 aria-expanded="false"
17 aria-controls="hidden-content"
18 >
19 <span class="pf-v6-c-button__icon pf-m-start">
20 <span class="pf-v6-c-expandable-section__toggle-icon">
21 <svg
22 class="pf-v6-svg"
23 fill="currentColor"
24 viewBox="0 0 20 20"
25 aria-hidden="true"
26 role="img"
27 width="1em"
28 height="1em"
29 >
30 <path
31 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
32 />
33 </svg>
34 </span>
35 </span>
36 <span class="pf-v6-c-button__text">Show more hidden example content</span>
37 </button>
38 </div>
39 <div
40 class="pf-v6-c-expandable-section__content"
41 hidden
42 id="hidden-content"
43 role="region"
44 aria-labelledby="hidden-toggle"
45 >This content is visible only when the component is expanded.</div>
46 </div>
47
48 ```
49
50 ### Expanded
51
52 ```html
53 <div class="pf-v6-c-expandable-section pf-m-expanded">
54 <div class="pf-v6-c-expandable-section__toggle">
55 <button
56 class="pf-v6-c-button pf-m-link"
57 id="expanded-toggle"
58 type="button"
59 aria-expanded="true"
60 aria-controls="expanded-content"
61 >
62 <span class="pf-v6-c-button__icon pf-m-start">
63 <span class="pf-v6-c-expandable-section__toggle-icon">
64 <svg
65 class="pf-v6-svg"
66 fill="currentColor"
67 viewBox="0 0 20 20"
68 aria-hidden="true"
69 role="img"
70 width="1em"
71 height="1em"
72 >
73 <path
74 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
75 />
76 </svg>
77 </span>
78 </span>
79 <span class="pf-v6-c-button__text">Show less expanded example content</span>
80 </button>
81 </div>
82 <div
83 class="pf-v6-c-expandable-section__content"
84 id="expanded-content"
85 role="region"
86 aria-labelledby="expanded-toggle"
87 >This content is visible only when the component is expanded.</div>
88 </div>
89
90 ```
91
92 ### Indented
93
94 ```html
95 <div class="pf-v6-c-expandable-section pf-m-expanded pf-m-indented">
96 <div class="pf-v6-c-expandable-section__toggle">
97 <button
98 class="pf-v6-c-button pf-m-link"
99 id="indented-toggle"
100 type="button"
101 aria-expanded="true"
102 aria-controls="indented-content"
103 >
104 <span class="pf-v6-c-button__icon pf-m-start">
105 <span class="pf-v6-c-expandable-section__toggle-icon">
106 <svg
107 class="pf-v6-svg"
108 fill="currentColor"
109 viewBox="0 0 20 20"
110 aria-hidden="true"
111 role="img"
112 width="1em"
113 height="1em"
114 >
115 <path
116 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
117 />
118 </svg>
119 </span>
120 </span>
121 <span class="pf-v6-c-button__text">Show less indented example content</span>
122 </button>
123 </div>
124 <div
125 class="pf-v6-c-expandable-section__content"
126 id="indented-content"
127 role="region"
128 aria-labelledby="indented-toggle"
129 >This content is visible only when the component is expanded.</div>
130 </div>
131
132 ```
133
134 ### Disclosure variation (hidden)
135
136 ```html
137 <div class="pf-v6-c-expandable-section pf-m-display-lg pf-m-limit-width">
138 <div class="pf-v6-c-expandable-section__toggle">
139 <button
140 class="pf-v6-c-button pf-m-link"
141 id="disclosure-variation-hidden-toggle"
142 type="button"
143 aria-expanded="false"
144 aria-controls="disclosure-variation-hidden-content"
145 >
146 <span class="pf-v6-c-button__icon pf-m-start">
147 <span class="pf-v6-c-expandable-section__toggle-icon">
148 <svg
149 class="pf-v6-svg"
150 fill="currentColor"
151 viewBox="0 0 20 20"
152 aria-hidden="true"
153 role="img"
154 width="1em"
155 height="1em"
156 >
157 <path
158 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
159 />
160 </svg>
161 </span>
162 </span>
163 <span
164 class="pf-v6-c-button__text"
165 >Show more disclosure variation example content</span>
166 </button>
167 </div>
168 <div
169 class="pf-v6-c-expandable-section__content"
170 hidden
171 id="disclosure-variation-hidden-content"
172 role="region"
173 aria-labelledby="disclosure-variation-hidden-toggle"
174 >This content is visible only when the component is expanded.</div>
175 </div>
176
177 ```
178
179 ### Disclosure variation (expanded)
180
181 ```html
182 <div
183 class="pf-v6-c-expandable-section pf-m-expanded pf-m-display-lg pf-m-limit-width"
184 >
185 <div class="pf-v6-c-expandable-section__toggle">
186 <button
187 class="pf-v6-c-button pf-m-link"
188 id="disclosure-variation-expanded-toggle"
189 type="button"
190 aria-expanded="true"
191 aria-controls="disclosure-variation-expanded-content"
192 >
193 <span class="pf-v6-c-button__icon pf-m-start">
194 <span class="pf-v6-c-expandable-section__toggle-icon">
195 <svg
196 class="pf-v6-svg"
197 fill="currentColor"
198 viewBox="0 0 20 20"
199 aria-hidden="true"
200 role="img"
201 width="1em"
202 height="1em"
203 >
204 <path
205 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
206 />
207 </svg>
208 </span>
209 </span>
210 <span
211 class="pf-v6-c-button__text"
212 >Show less disclosure variation example content</span>
213 </button>
214 </div>
215 <div
216 class="pf-v6-c-expandable-section__content"
217 id="disclosure-variation-expanded-content"
218 role="region"
219 aria-labelledby="disclosure-variation-expanded-toggle"
220 >This content is visible only when the component is expanded.</div>
221 </div>
222
223 ```
224
225 ### Disclosure variation (indented)
226
227 ```html
228 <div
229 class="pf-v6-c-expandable-section pf-m-expanded pf-m-display-lg pf-m-limit-width pf-m-indented"
230 >
231 <div class="pf-v6-c-expandable-section__toggle">
232 <button
233 class="pf-v6-c-button pf-m-link"
234 id="disclosure-variation-indented-toggle"
235 type="button"
236 aria-expanded="true"
237 aria-controls="disclosure-variation-indented-content"
238 >
239 <span class="pf-v6-c-button__icon pf-m-start">
240 <span class="pf-v6-c-expandable-section__toggle-icon">
241 <svg
242 class="pf-v6-svg"
243 fill="currentColor"
244 viewBox="0 0 20 20"
245 aria-hidden="true"
246 role="img"
247 width="1em"
248 height="1em"
249 >
250 <path
251 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
252 />
253 </svg>
254 </span>
255 </span>
256 <span
257 class="pf-v6-c-button__text"
258 >Show less disclosure variation indented example content</span>
259 </button>
260 </div>
261 <div
262 class="pf-v6-c-expandable-section__content"
263 id="disclosure-variation-indented-content"
264 role="region"
265 aria-labelledby="disclosure-variation-indented-toggle"
266 >This content is visible only when the component is expanded.</div>
267 </div>
268
269 ```
270
271 ### Detached
272
273 ```html
274 <div class="pf-v6-l-stack pf-m-gutter">
275 <div class="pf-v6-l-stack__item">
276 <div
277 class="pf-v6-c-expandable-section pf-m-expanded pf-m-detached pf-m-expand-top"
278 >
279 <div
280 class="pf-v6-c-expandable-section__content"
281 id="detached-toggle-content"
282 role="region"
283 aria-labelledby="detached-toggle-toggle"
284 >This content is visible only when the component is expanded.</div>
285 </div>
286 </div>
287
288 <div class="pf-v6-l-stack__item">
289 <div
290 class="pf-v6-c-expandable-section pf-m-expanded pf-m-detached pf-m-expand-top"
291 >
292 <div class="pf-v6-c-expandable-section__toggle">
293 <button
294 class="pf-v6-c-button pf-m-link"
295 id="detached-toggle-toggle"
296 type="button"
297 aria-expanded="true"
298 aria-controls="detached-toggle-content"
299 >
300 <span class="pf-v6-c-button__icon pf-m-start">
301 <span class="pf-v6-c-expandable-section__toggle-icon">
302 <svg
303 class="pf-v6-svg"
304 fill="currentColor"
305 viewBox="0 0 20 20"
306 aria-hidden="true"
307 role="img"
308 width="1em"
309 height="1em"
310 >
311 <path
312 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
313 />
314 </svg>
315 </span>
316 </span>
317 <span class="pf-v6-c-button__text">Show less detached example content</span>
318 </button>
319 </div>
320 </div>
321 </div>
322 </div>
323
324 ```
325
326 ### Truncate expansion (hidden)
327
328 ```html
329 <div class="pf-v6-c-expandable-section pf-m-truncate">
330 <div
331 class="pf-v6-c-expandable-section__content"
332 id="truncated-expansion-hidden-content"
333 role="region"
334 aria-labelledby="truncated-expansion-hidden-toggle"
335 >Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus finibus, diam vitae eleifend consequat, metus sapien posuere quam, ut tincidunt nunc enim eget sapien. Mauris ac dui imperdiet dolor dignissim efficitur laoreet quis erat. Proin turpis leo, malesuada eget urna et, tristique mollis odio. Ut mattis nulla lorem, elementum hendrerit nunc molestie vitae. Proin massa sem, bibendum id urna in, viverra porta neque. Ut ut mi ac lacus rhoncus mollis id quis sem. Suspendisse non justo elementum, dictum eros nec, hendrerit sapien. Mauris aliquet, est sit amet tincidunt vehicula, purus est hendrerit arcu, vitae egestas odio lorem ut lacus. In et neque non metus viverra rhoncus quis non purus. Integer id venenatis tortor. Nulla sollicitudin convallis tellus, at porta eros volutpat in. Curabitur rhoncus rhoncus nisi, sit amet tincidunt dolor efficitur vitae. Integer purus neque, porta non odio lobortis, accumsan elementum risus. Pellentesque viverra id lacus a cursus. Etiam eu pulvinar risus. Etiam ultrices nec urna id consequat.</div>
336 <div class="pf-v6-c-expandable-section__toggle">
337 <button
338 class="pf-v6-c-button pf-m-inline pf-m-link"
339 id="truncated-expansion-hidden-toggle"
340 type="button"
341 aria-expanded="false"
342 aria-controls="truncated-expansion-hidden-content"
343 >
344 <span class="pf-v6-c-button__text">Show more truncated content</span>
345 </button>
346 </div>
347 </div>
348
349 ```
350
351 ### Truncate expansion (expanded)
352
353 ```html
354 <div class="pf-v6-c-expandable-section pf-m-expanded pf-m-truncate">
355 <div
356 class="pf-v6-c-expandable-section__content"
357 id="truncate-expansion-expanded-content"
358 role="region"
359 aria-labelledby="truncate-expansion-expanded-toggle"
360 >Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus finibus, diam vitae eleifend consequat, metus sapien posuere quam, ut tincidunt nunc enim eget sapien. Mauris ac dui imperdiet dolor dignissim efficitur laoreet quis erat. Proin turpis leo, malesuada eget urna et, tristique mollis odio. Ut mattis nulla lorem, elementum hendrerit nunc molestie vitae. Proin massa sem, bibendum id urna in, viverra porta neque. Ut ut mi ac lacus rhoncus mollis id quis sem. Suspendisse non justo elementum, dictum eros nec, hendrerit sapien. Mauris aliquet, est sit amet tincidunt vehicula, purus est hendrerit arcu, vitae egestas odio lorem ut lacus. In et neque non metus viverra rhoncus quis non purus. Integer id venenatis tortor. Nulla sollicitudin convallis tellus, at porta eros volutpat in. Curabitur rhoncus rhoncus nisi, sit amet tincidunt dolor efficitur vitae. Integer purus neque, porta non odio lobortis, accumsan elementum risus. Pellentesque viverra id lacus a cursus. Etiam eu pulvinar risus. Etiam ultrices nec urna id consequat.</div>
361 <div class="pf-v6-c-expandable-section__toggle">
362 <button
363 class="pf-v6-c-button pf-m-inline pf-m-link"
364 id="truncate-expansion-expanded-toggle"
365 type="button"
366 aria-expanded="true"
367 aria-controls="truncate-expansion-expanded-content"
368 >
369 <span class="pf-v6-c-button__text">Show less truncated content</span>
370 </button>
371 </div>
372 </div>
373
374 ```
375
376 ## Documentation
377
378 ### Accessibility
379
380 | Attribute | Applied to | Outcome |
381 | -- | -- | -- |
382 | `aria-expanded="true"` | `.pf-v6-c-expandable-section__toggle .pf-v6-c-button` | Indicates that the expandable section content is visible. **Required** |
383 | `aria-expanded="false"` | `.pf-v6-c-expandable-section__toggle .pf-v6-c-button` | Indicates the the expandable section content is hidden. **Required** |
384 | `hidden` | `.pf-v6-c-expandable-section__content` | Indicates that the expandable section content element is hidden. Use with `aria-expanded="false"` **Required** |
385 | `aria-hidden="true"` | `.pf-v6-c-expandable-section__toggle-icon` | Hides the icon from screen readers. **Required** |
386 | `aria-controls="[id of content element]"` | `.pf-v6-c-expandable-section.pf-m-detached .pf-v6-c-expandable-section__toggle .pf-v6-c-button` | Identifies the element controlled by the toggle button. **Required** |
387 | `id` | `.pf-v6-c-expandable-section.pf-m-detached .pf-v6-c-expandable-section__content` | Gives the content an `id` for use with `aria-controls` on `.pf-v6-c-expandable-section__toggle .pf-v6-c-button`. **Required** |
388
389 ### Usage
390
391 | Class | Applied to | Outcome |
392 | -- | -- | -- |
393 | `.pf-v6-c-expandable-section` | `<div>` | Initiates the expandable section component. **Required** |
394 | `.pf-v6-c-expandable-section__toggle` | `<div>` | Initiates the expandable toggle wrapper. **Required** |
395 | `.pf-v6-c-expandable-section__toggle-icon` | `<span>` | Initiates the expandable toggle icon. **Required** |
396 | `.pf-v6-c-expandable-section__content` | `<div>` | Initiates the expandable section content. **Required** |
397 | `.pf-m-expanded` | `.pf-v6-c-expandable-section` | Modifies the component for the expanded state. |
398 | `.pf-m-detached` | `.pf-v6-c-expandable-section` | Modifies the component for a detached variant. |
399 | `.pf-m-expand-top` | `.pf-v6-c-expandable-section__toggle-icon` | Modifies the toggle icon to point up when expanded. We recommend the new method of applying this class directly to the `.pf-v6-c-expandable-section` wrapper element. |
400 | `.pf-m-expand-top` | `.pf-v6-c-expandable-section.pf-m-detached` | Modifies the expandable animation and icon rotation directions for detached expandable sections. **Required** when the content is above the toggle. |
401 | `.pf-m-expand-bottom` | `.pf-v6-c-expandable-section.pf-m-detached` | Modifies the expandable animation direction for detached expandable sections. **Required** when the content is below the toggle. |
402 | `.pf-m-display-lg` | `.pf-v6-c-expandable-section` | Modifies the styling of the component to have large display styling. |
403 | `.pf-m-indented` | `.pf-v6-c-expandable-section` | Indicates that the expandable section content is indented and is aligned with the start of the title text to provide visual hierarchy. |
404 | `.pf-m-truncate` | `.pf-v6-c-expandable-section` | Indicates that the expandable section content is truncated by default, and not truncated when expanded. |
405 | `--pf-v6-c-expandable-section--m-truncate__content--LineClamp` | `.pf-v6-c-expandable-section.pf-m-truncate` | Modifies the number of lines to show before truncating. |