Debian Codegraph @

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

raw
1 ---
2 id: Modal
3 section: components
4 cssPrefix: pf-v6-c-modal-box
5 ---import './ModalBox.css'
6
7 ## Examples
8
9 ### Basic
10
11 ```html isFullscreen
12 <div
13 class="pf-v6-c-modal-box"
14 role="dialog"
15 aria-modal="true"
16 aria-labelledby="modal-title"
17 aria-describedby="modal-description"
18 >
19 <div class="pf-v6-c-modal-box__close">
20 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
21 <span class="pf-v6-c-button__icon">
22 <svg
23 class="pf-v6-svg"
24 fill="currentColor"
25 viewBox="0 0 20 20"
26 aria-hidden="true"
27 role="img"
28 width="1em"
29 height="1em"
30 >
31 <path
32 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
33 />
34 </svg>
35 </span>
36 </button>
37 </div>
38 <header class="pf-v6-c-modal-box__header">
39 <div class="pf-v6-c-modal-box__header-main">
40 <h1 class="pf-v6-c-modal-box__title" id="modal-title">Modal title</h1>
41 </div>
42 </header>
43 <div
44 class="pf-v6-c-modal-box__body"
45 id="modal-description"
46 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
47 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
48 </div>
49
50 ```
51
52 ### With help button
53
54 ```html isFullscreen
55 <div
56 class="pf-v6-c-modal-box"
57 role="dialog"
58 aria-modal="true"
59 aria-labelledby="modal-help-title"
60 aria-describedby="modal-help-description"
61 >
62 <div class="pf-v6-c-modal-box__close">
63 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
64 <span class="pf-v6-c-button__icon">
65 <svg
66 class="pf-v6-svg"
67 fill="currentColor"
68 viewBox="0 0 20 20"
69 aria-hidden="true"
70 role="img"
71 width="1em"
72 height="1em"
73 >
74 <path
75 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
76 />
77 </svg>
78 </span>
79 </button>
80 </div>
81 <header class="pf-v6-c-modal-box__header pf-m-help">
82 <div class="pf-v6-c-modal-box__header-main">
83 <h1
84 class="pf-v6-c-modal-box__title"
85 id="modal-help-title"
86 >Modal title Modal title Modal title Modal title Modal title Modal title Modal title Modal title</h1>
87 <div
88 class="pf-v6-c-modal-box__description"
89 id="modal-help-description"
90 >A description is used when you want to provide more info about the modal than the title is able to describe. The content in the description is static and will not scroll with the rest of the modal body.</div>
91 </div>
92 <div class="pf-v6-c-modal-box__header-help">
93 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Help">
94 <span class="pf-v6-c-button__icon">
95 <svg
96 class="pf-v6-svg"
97 fill="currentColor"
98 viewBox="0 0 32 32"
99 aria-hidden="true"
100 role="img"
101 width="1em"
102 height="1em"
103 >
104 <path
105 d="M16 1C7.729 1 1 7.729 1 16s6.729 15 15 15 15-6.729 15-15S24.271 1 16 1Zm0 28C8.832 29 3 23.168 3 16S8.832 3 16 3s13 5.832 13 13-5.832 13-13 13Zm5-17a5.008 5.008 0 0 1-4 4.899V19a1 1 0 0 1-2 0v-3a1 1 0 0 1 1-1c1.654 0 3-1.346 3-3s-1.346-3-3-3-3 1.346-3 3a1 1 0 0 1-2 0c0-2.757 2.243-5 5-5s5 2.243 5 5Zm-3.25 12a1.75 1.75 0 1 1-3.501-.001A1.75 1.75 0 0 1 17.75 24Z"
106 />
107 </svg>
108 </span>
109 </button>
110 </div>
111 </header>
112 <div
113 class="pf-v6-c-modal-box__body"
114 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
115 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
116 </div>
117
118 ```
119
120 ### Small
121
122 ```html isFullscreen
123 <div
124 class="pf-v6-c-modal-box pf-m-sm"
125 role="dialog"
126 aria-modal="true"
127 aria-labelledby="modal-sm-title"
128 aria-describedby="modal-sm-description"
129 >
130 <div class="pf-v6-c-modal-box__close">
131 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
132 <span class="pf-v6-c-button__icon">
133 <svg
134 class="pf-v6-svg"
135 fill="currentColor"
136 viewBox="0 0 20 20"
137 aria-hidden="true"
138 role="img"
139 width="1em"
140 height="1em"
141 >
142 <path
143 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
144 />
145 </svg>
146 </span>
147 </button>
148 </div>
149 <header class="pf-v6-c-modal-box__header">
150 <div class="pf-v6-c-modal-box__header-main">
151 <h1 class="pf-v6-c-modal-box__title" id="modal-sm-title">Modal title</h1>
152 </div>
153 </header>
154 <div class="pf-v6-c-modal-box__body" id="modal-sm-description">
155 Static text describing modal purpose. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
156 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
157 quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
158 consequat.
159 </div>
160 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
161 </div>
162
163 ```
164
165 ### Medium
166
167 ```html isFullscreen
168 <div
169 class="pf-v6-c-modal-box pf-m-md"
170 role="dialog"
171 aria-modal="true"
172 aria-labelledby="modal-md-title"
173 aria-describedby="modal-md-description"
174 >
175 <div class="pf-v6-c-modal-box__close">
176 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
177 <span class="pf-v6-c-button__icon">
178 <svg
179 class="pf-v6-svg"
180 fill="currentColor"
181 viewBox="0 0 20 20"
182 aria-hidden="true"
183 role="img"
184 width="1em"
185 height="1em"
186 >
187 <path
188 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
189 />
190 </svg>
191 </span>
192 </button>
193 </div>
194 <header class="pf-v6-c-modal-box__header">
195 <div class="pf-v6-c-modal-box__header-main">
196 <h1 class="pf-v6-c-modal-box__title" id="modal-md-title">Modal title</h1>
197 </div>
198 </header>
199 <div class="pf-v6-c-modal-box__body" id="modal-md-description">
200 Static text describing modal purpose. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
201 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
202 quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
203 consequat.
204 </div>
205 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
206 </div>
207
208 ```
209
210 ### Large
211
212 ```html isFullscreen
213 <div
214 class="pf-v6-c-modal-box pf-m-lg"
215 role="dialog"
216 aria-modal="true"
217 aria-labelledby="modal-lg-title"
218 aria-describedby="modal-lg-description"
219 >
220 <div class="pf-v6-c-modal-box__close">
221 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
222 <span class="pf-v6-c-button__icon">
223 <svg
224 class="pf-v6-svg"
225 fill="currentColor"
226 viewBox="0 0 20 20"
227 aria-hidden="true"
228 role="img"
229 width="1em"
230 height="1em"
231 >
232 <path
233 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
234 />
235 </svg>
236 </span>
237 </button>
238 </div>
239 <header class="pf-v6-c-modal-box__header">
240 <div class="pf-v6-c-modal-box__header-main">
241 <h1 class="pf-v6-c-modal-box__title" id="modal-lg-title">Modal title</h1>
242 </div>
243 </header>
244 <div class="pf-v6-c-modal-box__body" id="modal-lg-description">
245 Static text describing modal purpose. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
246 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
247 quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
248 consequat.
249 </div>
250 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
251 </div>
252
253 ```
254
255 ### Without title
256
257 ```html isFullscreen
258 <div
259 class="pf-v6-c-modal-box"
260 role="dialog"
261 aria-modal="true"
262 aria-label="Example of a modal without a title"
263 aria-describedby="modal-no-title-description"
264 >
265 <div class="pf-v6-c-modal-box__close">
266 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
267 <span class="pf-v6-c-button__icon">
268 <svg
269 class="pf-v6-svg"
270 fill="currentColor"
271 viewBox="0 0 20 20"
272 aria-hidden="true"
273 role="img"
274 width="1em"
275 height="1em"
276 >
277 <path
278 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
279 />
280 </svg>
281 </span>
282 </button>
283 </div>
284 <div class="pf-v6-c-modal-box__body">
285 <span
286 id="modal-no-title-description"
287 >When static text describing the modal is available, it can be wrapped with an ID referring to the modal's aria-describedby value. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</span> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
288 </div>
289 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
290 </div>
291
292 ```
293
294 ### With description
295
296 ```html isFullscreen
297 <div
298 class="pf-v6-c-modal-box"
299 role="dialog"
300 aria-modal="true"
301 aria-labelledby="modal-with-description-title"
302 aria-describedby="modal-with-description-description"
303 >
304 <div class="pf-v6-c-modal-box__close">
305 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
306 <span class="pf-v6-c-button__icon">
307 <svg
308 class="pf-v6-svg"
309 fill="currentColor"
310 viewBox="0 0 20 20"
311 aria-hidden="true"
312 role="img"
313 width="1em"
314 height="1em"
315 >
316 <path
317 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
318 />
319 </svg>
320 </span>
321 </button>
322 </div>
323 <header class="pf-v6-c-modal-box__header">
324 <div class="pf-v6-c-modal-box__header-main">
325 <h1
326 class="pf-v6-c-modal-box__title"
327 id="modal-with-description-title"
328 >Modal title</h1>
329 <div
330 class="pf-v6-c-modal-box__description"
331 id="modal-with-description-description"
332 >A description is used when you want to provide more info about the modal than the title is able to describe. The content in the description is static and will not scroll with the rest of the modal body.</div>
333 </div>
334 </header>
335 <div
336 class="pf-v6-c-modal-box__body"
337 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
338 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
339 </div>
340
341 ```
342
343 ### Custom title
344
345 ```html isFullscreen
346 <div
347 class="pf-v6-c-modal-box"
348 role="dialog"
349 aria-modal="true"
350 aria-labelledby="modal-custom-title"
351 aria-describedby="modal-custom-description"
352 >
353 <div class="pf-v6-c-modal-box__close">
354 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
355 <span class="pf-v6-c-button__icon">
356 <svg
357 class="pf-v6-svg"
358 fill="currentColor"
359 viewBox="0 0 20 20"
360 aria-hidden="true"
361 role="img"
362 width="1em"
363 height="1em"
364 >
365 <path
366 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
367 />
368 </svg>
369 </span>
370 </button>
371 </div>
372 <header class="pf-v6-c-modal-box__header">
373 <div class="pf-v6-c-modal-box__header-main">
374 <h1 class="pf-v6-c-title pf-m-4xl" id="modal-custom-title">Custom title</h1>
375 </div>
376 </header>
377 <div
378 class="pf-v6-c-modal-box__body"
379 id="modal-custom-description"
380 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
381 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
382 </div>
383
384 ```
385
386 ### Modal box as generic container
387
388 ```html isFullscreen
389 <div
390 class="pf-v6-c-modal-box"
391 role="dialog"
392 aria-modal="true"
393 aria-labelledby="modal-generic-container-description"
394 >
395 <p
396 id="modal-generic-container-description"
397 >The modal box children elements can be removed, and the modal serves as a generic modal container. One use case of this is when creating a wizard in a modal.</p>
398 </div>
399
400 ```
401
402 ### Icon
403
404 ```html isFullscreen
405 <div
406 class="pf-v6-c-modal-box"
407 role="dialog"
408 aria-modal="true"
409 aria-labelledby="icon-title"
410 aria-describedby="icon-description"
411 >
412 <div class="pf-v6-c-modal-box__close">
413 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
414 <span class="pf-v6-c-button__icon">
415 <svg
416 class="pf-v6-svg"
417 fill="currentColor"
418 viewBox="0 0 20 20"
419 aria-hidden="true"
420 role="img"
421 width="1em"
422 height="1em"
423 >
424 <path
425 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
426 />
427 </svg>
428 </span>
429 </button>
430 </div>
431 <header class="pf-v6-c-modal-box__header">
432 <div class="pf-v6-c-modal-box__header-main">
433 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="icon-title">
434 <span class="pf-v6-c-modal-box__title-icon">
435 <svg
436 class="pf-v6-svg"
437 fill="currentColor"
438 viewBox="0 0 32 32"
439 aria-hidden="true"
440 role="img"
441 width="1em"
442 height="1em"
443 >
444 <path
445 d="M18 3v26a1 1 0 0 1-1.614.789L7.657 23H2.5c-.827 0-1.5-.673-1.5-1.5v-11C1 9.673 1.673 9 2.5 9h5.157l8.729-6.789A1 1 0 0 1 18.001 3Zm8.716 2.512a1 1 0 1 0-1.432 1.396C27.68 9.363 29 12.592 29 16s-1.319 6.637-3.716 9.092a.999.999 0 1 0 1.432 1.396C29.479 23.658 31 19.932 31 16s-1.521-7.658-4.284-10.488Zm-3.965 4.538a1 1 0 0 0-1.502 1.32C22.378 12.654 23 14.298 23 16s-.622 3.346-1.751 4.63a1 1 0 0 0 1.502 1.32C24.201 20.302 25 18.188 25 16s-.799-4.302-2.249-5.95Z"
446 />
447 </svg>
448 </span>
449 <span class="pf-v6-c-modal-box__title-text">Modal with icon title</span>
450 </h1>
451 </div>
452 </header>
453 <div class="pf-v6-c-modal-box__body" id="icon-description">Modal description</div>
454 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
455 </div>
456
457 ```
458
459 ### Custom alert
460
461 ```html isFullscreen
462 <div
463 class="pf-v6-c-modal-box pf-m-custom"
464 role="dialog"
465 aria-modal="true"
466 aria-labelledby="custom-alert-title"
467 aria-describedby="custom-alert-description"
468 >
469 <div class="pf-v6-c-modal-box__close">
470 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
471 <span class="pf-v6-c-button__icon">
472 <svg
473 class="pf-v6-svg"
474 fill="currentColor"
475 viewBox="0 0 20 20"
476 aria-hidden="true"
477 role="img"
478 width="1em"
479 height="1em"
480 >
481 <path
482 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
483 />
484 </svg>
485 </span>
486 </button>
487 </div>
488 <header class="pf-v6-c-modal-box__header">
489 <div class="pf-v6-c-modal-box__header-main">
490 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="custom-alert-title">
491 <span class="pf-v6-c-modal-box__title-icon">
492 <svg
493 class="pf-v6-svg"
494 fill="currentColor"
495 viewBox="0 0 32 32"
496 aria-hidden="true"
497 role="img"
498 width="1em"
499 height="1em"
500 >
501 <path
502 d="M28.75 22v3.5c0 .689-.561 1.25-1.25 1.25h-7.521c.005.084.021.166.021.25 0 2.206-1.794 4-4 4s-4-1.794-4-4c0-.084.016-.166.021-.25H4.5c-.689 0-1.25-.561-1.25-1.25V22a.75.75 0 0 1 .75-.75c1.24 0 2.25-1.009 2.25-2.25v-4c0-4.826 3.528-8.833 8.138-9.605A2.482 2.482 0 0 1 13.5 3.5C13.5 2.122 14.621 1 16 1s2.5 1.122 2.5 2.5c0 .761-.349 1.436-.888 1.895 4.61.772 8.138 4.779 8.138 9.605v4c0 1.241 1.01 2.25 2.25 2.25a.75.75 0 0 1 .75.75Z"
503 />
504 </svg>
505 </span>
506 <span class="pf-v6-u-screen-reader">
507 Default
508 alert:
509 </span>
510 <span class="pf-v6-c-modal-box__title-text">Custom alert modal title</span>
511 </h1>
512 </div>
513 </header>
514 <div
515 class="pf-v6-c-modal-box__body"
516 id="custom-alert-description"
517 >Modal description</div>
518 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
519 </div>
520
521 ```
522
523 ### Info alert
524
525 ```html isFullscreen
526 <div
527 class="pf-v6-c-modal-box pf-m-info"
528 role="dialog"
529 aria-modal="true"
530 aria-labelledby="info-alert-title"
531 aria-describedby="info-alert-description"
532 >
533 <div class="pf-v6-c-modal-box__close">
534 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
535 <span class="pf-v6-c-button__icon">
536 <svg
537 class="pf-v6-svg"
538 fill="currentColor"
539 viewBox="0 0 20 20"
540 aria-hidden="true"
541 role="img"
542 width="1em"
543 height="1em"
544 >
545 <path
546 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
547 />
548 </svg>
549 </span>
550 </button>
551 </div>
552 <header class="pf-v6-c-modal-box__header">
553 <div class="pf-v6-c-modal-box__header-main">
554 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="info-alert-title">
555 <span class="pf-v6-c-modal-box__title-icon">
556 <svg
557 class="pf-v6-svg"
558 fill="currentColor"
559 viewBox="0 0 32 32"
560 aria-hidden="true"
561 role="img"
562 width="1em"
563 height="1em"
564 >
565 <path
566 d="M16 1C7.729 1 1 7.729 1 16s6.729 15 15 15 15-6.729 15-15S24.271 1 16 1Zm1.5 22a1.5 1.5 0 1 1-3 0v-5.157l-.188.04a1.5 1.5 0 0 1-.625-2.934l1.956-.416c.112-.024.223-.032.333-.03l.024-.002a1.5 1.5 0 0 1 1.5 1.5v7Zm-.08-12.58c-.38.37-.89.58-1.42.58a1.998 1.998 0 0 1-1.851-2.76c.051-.13.11-.24.19-.35.07-.11.15-.21.25-.3.74-.75 2.08-.75 2.83 0 .09.09.17.19.24.3.08.11.14.22.189.35.05.12.09.24.11.37.03.13.04.26.04.39 0 .53-.21 1.04-.58 1.42Z"
567 />
568 </svg>
569 </span>
570 <span class="pf-v6-u-screen-reader">
571 Info
572 alert:
573 </span>
574 <span class="pf-v6-c-modal-box__title-text">Info alert modal title</span>
575 </h1>
576 </div>
577 </header>
578 <div
579 class="pf-v6-c-modal-box__body"
580 id="info-alert-description"
581 >Modal description</div>
582 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
583 </div>
584
585 ```
586
587 ### Success alert
588
589 ```html isFullscreen
590 <div
591 class="pf-v6-c-modal-box pf-m-success"
592 role="dialog"
593 aria-modal="true"
594 aria-labelledby="success-alert-title"
595 aria-describedby="success-alert-description"
596 >
597 <div class="pf-v6-c-modal-box__close">
598 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
599 <span class="pf-v6-c-button__icon">
600 <svg
601 class="pf-v6-svg"
602 fill="currentColor"
603 viewBox="0 0 20 20"
604 aria-hidden="true"
605 role="img"
606 width="1em"
607 height="1em"
608 >
609 <path
610 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
611 />
612 </svg>
613 </span>
614 </button>
615 </div>
616 <header class="pf-v6-c-modal-box__header">
617 <div class="pf-v6-c-modal-box__header-main">
618 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="success-alert-title">
619 <span class="pf-v6-c-modal-box__title-icon">
620 <svg
621 class="pf-v6-svg"
622 fill="currentColor"
623 viewBox="0 0 32 32"
624 aria-hidden="true"
625 role="img"
626 width="1em"
627 height="1em"
628 >
629 <path
630 d="M16 1C7.729 1 1 7.729 1 16s6.729 15 15 15 15-6.729 15-15S24.271 1 16 1Zm7.795 11.795-8.646 8.646c-.317.317-.733.475-1.149.475s-.832-.158-1.149-.475l-4.646-4.646a1.126 1.126 0 0 1 1.591-1.591l4.205 4.205 8.205-8.205a1.126 1.126 0 0 1 1.591 1.591Z"
631 />
632 </svg>
633 </span>
634 <span class="pf-v6-u-screen-reader">
635 Success
636 alert:
637 </span>
638 <span class="pf-v6-c-modal-box__title-text">Success alert modal title</span>
639 </h1>
640 </div>
641 </header>
642 <div
643 class="pf-v6-c-modal-box__body"
644 id="success-alert-description"
645 >Modal description</div>
646 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
647 </div>
648
649 ```
650
651 ### Warning alert
652
653 ```html isFullscreen
654 <div
655 class="pf-v6-c-modal-box pf-m-warning"
656 role="dialog"
657 aria-modal="true"
658 aria-labelledby="warning-alert-title"
659 aria-describedby="warning-alert-description"
660 >
661 <div class="pf-v6-c-modal-box__close">
662 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
663 <span class="pf-v6-c-button__icon">
664 <svg
665 class="pf-v6-svg"
666 fill="currentColor"
667 viewBox="0 0 20 20"
668 aria-hidden="true"
669 role="img"
670 width="1em"
671 height="1em"
672 >
673 <path
674 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
675 />
676 </svg>
677 </span>
678 </button>
679 </div>
680 <header class="pf-v6-c-modal-box__header">
681 <div class="pf-v6-c-modal-box__header-main">
682 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="warning-alert-title">
683 <span class="pf-v6-c-modal-box__title-icon">
684 <svg
685 class="pf-v6-svg"
686 fill="currentColor"
687 viewBox="0 0 32 32"
688 aria-hidden="true"
689 role="img"
690 width="1em"
691 height="1em"
692 >
693 <path
694 d="m31.874 28.514-15.011-27a1.001 1.001 0 0 0-1.748 0l-15.011 27A1 1 0 0 0 .978 30H31a1 1 0 0 0 .874-1.486ZM14.5 12a1.5 1.5 0 0 1 3 0v5a1.5 1.5 0 0 1-3 0v-5ZM16 26.001a2 2 0 1 1-.001-3.999A2 2 0 0 1 16 26.001Z"
695 />
696 </svg>
697 </span>
698 <span class="pf-v6-u-screen-reader">
699 Warning
700 alert:
701 </span>
702 <span class="pf-v6-c-modal-box__title-text">Warning alert modal title</span>
703 </h1>
704 </div>
705 </header>
706 <div
707 class="pf-v6-c-modal-box__body"
708 id="warning-alert-description"
709 >Modal description</div>
710 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
711 </div>
712
713 ```
714
715 ### Danger alert
716
717 ```html isFullscreen
718 <div
719 class="pf-v6-c-modal-box pf-m-danger"
720 role="dialog"
721 aria-modal="true"
722 aria-labelledby="danger-alert-title"
723 aria-describedby="danger-alert-description"
724 >
725 <div class="pf-v6-c-modal-box__close">
726 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
727 <span class="pf-v6-c-button__icon">
728 <svg
729 class="pf-v6-svg"
730 fill="currentColor"
731 viewBox="0 0 20 20"
732 aria-hidden="true"
733 role="img"
734 width="1em"
735 height="1em"
736 >
737 <path
738 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
739 />
740 </svg>
741 </span>
742 </button>
743 </div>
744 <header class="pf-v6-c-modal-box__header">
745 <div class="pf-v6-c-modal-box__header-main">
746 <h1 class="pf-v6-c-modal-box__title pf-m-icon" id="danger-alert-title">
747 <span class="pf-v6-c-modal-box__title-icon">
748 <svg
749 class="pf-v6-svg"
750 fill="currentColor"
751 viewBox="0 0 32 32"
752 aria-hidden="true"
753 role="img"
754 width="1em"
755 height="1em"
756 >
757 <path
758 d="M16 1C7.729 1 1 7.729 1 16s6.729 15 15 15 15-6.729 15-15S24.271 1 16 1Zm-1.5 8a1.5 1.5 0 1 1 3 0v7a1.5 1.5 0 1 1-3 0V9ZM16 25.001a2 2 0 1 1-.001-3.999A2 2 0 0 1 16 25.001Z"
759 />
760 </svg>
761 </span>
762 <span class="pf-v6-u-screen-reader">
763 Danger
764 alert:
765 </span>
766 <span class="pf-v6-c-modal-box__title-text">Danger alert modal title</span>
767 </h1>
768 </div>
769 </header>
770 <div
771 class="pf-v6-c-modal-box__body"
772 id="danger-alert-description"
773 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
774 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
775 </div>
776
777 ```
778
779 ### Danger alert with modifier on modal title
780
781 The status modifier classes can be applied directly to the modal title element, instead of the parent modal.
782
783 ```html isFullscreen
784 <div
785 class="pf-v6-c-modal-box"
786 role="dialog"
787 aria-modal="true"
788 aria-labelledby="danger-alert-title-title"
789 aria-describedby="danger-alert-title-description"
790 >
791 <div class="pf-v6-c-modal-box__close">
792 <button class="pf-v6-c-button pf-m-plain" type="button" aria-label="Close">
793 <span class="pf-v6-c-button__icon">
794 <svg
795 class="pf-v6-svg"
796 fill="currentColor"
797 viewBox="0 0 20 20"
798 aria-hidden="true"
799 role="img"
800 width="1em"
801 height="1em"
802 >
803 <path
804 d="M17.8 16.2 11.59 10l6.21-6.21c.42-.46.39-1.17-.07-1.59-.43-.4-1.09-.4-1.52 0l-6.2 6.2-6.22-6.19c-.44-.44-1.15-.44-1.59 0-.44.44-.44 1.15 0 1.59l6.2 6.21-6.2 6.2c-.42.46-.39 1.17.07 1.59.43.4 1.09.4 1.52 0L10 11.59l6.2 6.2c.44.44 1.15.44 1.59 0 .44-.45.44-1.16 0-1.6Z"
805 />
806 </svg>
807 </span>
808 </button>
809 </div>
810 <header class="pf-v6-c-modal-box__header">
811 <div class="pf-v6-c-modal-box__header-main">
812 <h1
813 class="pf-v6-c-modal-box__title pf-m-icon pf-m-danger"
814 id="danger-alert-title-title"
815 >
816 <span class="pf-v6-c-modal-box__title-icon">
817 <svg
818 class="pf-v6-svg"
819 fill="currentColor"
820 viewBox="0 0 32 32"
821 aria-hidden="true"
822 role="img"
823 width="1em"
824 height="1em"
825 >
826 <path
827 d="M16 1C7.729 1 1 7.729 1 16s6.729 15 15 15 15-6.729 15-15S24.271 1 16 1Zm-1.5 8a1.5 1.5 0 1 1 3 0v7a1.5 1.5 0 1 1-3 0V9ZM16 25.001a2 2 0 1 1-.001-3.999A2 2 0 0 1 16 25.001Z"
828 />
829 </svg>
830 </span>
831 <span class="pf-v6-u-screen-reader">
832 Danger
833 alert:
834 </span>
835 <span class="pf-v6-c-modal-box__title-text">Danger alert modal title</span>
836 </h1>
837 </div>
838 </header>
839 <div
840 class="pf-v6-c-modal-box__body"
841 id="danger-alert-title-description"
842 >To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.</div>
843 <footer class="pf-v6-c-modal-box__footer">Modal footer</footer>
844 </div>
845
846 ```
847
848 ## Documentation
849
850 ### Overview
851
852 A modal box is a generic rectangular container that can be used to build modals. A modal box can have the following sections: header, title, description, body, and footer. With normal use of the modal, a title or body is required. Alternatively, no child elements can be used, and the `.pf-v6-c-modal-box` container will serve as a generic container with no padding for custom modal content. If no `.pf-v6-c-modal-box__title` is used, `aria-label="[title of modal]"` must be provided for `.pf-v6-c-modal-box`.
853
854 ### Accessibility
855
856 | Attribute | Applies to | Outcome |
857 | -- | -- | -- |
858 | `role="dialog"` | `.pf-v6-c-modal-box` | Identifies the element that serves as the modal container. **Required** |
859 | `aria-labelledby="[id value of .pf-v6-c-modal-box__title or custom modal title]"` | `.pf-v6-c-modal-box` | Gives the modal an accessible name by referring to the element that provides the dialog title. **Required when .pf-v6-c-title is present** |
860 | `aria-label="[title of modal]"` | `.pf-v6-c-modal-box` | Gives the modal an accessible name. **Required when `.pf-v6-c-modal-box__title` is *not* present** |
861 | `aria-describedby="[id value of applicable content]"` | `.pf-v6-c-modal-box` | Gives the modal an accessible description by referring to the modal content that describes the primary message or purpose of the dialog. Not used if there is no static text that describes the modal. |
862 | `aria-modal="true"` | `.pf-v6-c-modal-box` | Tells assistive technologies that the windows underneath the current modal are not available for interaction. **Required**|
863 | `aria-label="Close"` | `.pf-v6-c-modal-box__close .pf-v6-c-button` | Provides an accessible name for the close button as it uses an icon instead of text. **Required**|
864 | `aria-hidden="true"` | Parent element containing the page contents when modal is open | Hides main contents of the page from screen readers. The element with `.pf-v6-c-modal-box` must not be a descendent of the element with `aria-hidden="true"`. For more info see [trapping focus](/accessibility/develop#trapping-focus). **Required** |
865 | `form="[id of form in modal body]"` | `.pf-v6-c-modal-box__footer .pf-v6-c-button` | Associates a submit button in the modal footer with a form in the modal body. For use when the submit button is outside of the `<form>` that the button submits. |
866 | `tabindex="0"` | `.pf-v6-c-modal-box__body` | If a modal box body has overflow content that triggers a scrollbar, to ensure that the content is keyboard accessible, the body must include either a focusable element within the scrollable region or the body itself must be focusable by adding `tabindex="0"`. |
867
868 ### Usage
869
870 | Class | Applied | Outcome |
871 | -- | -- | -- |
872 | `.pf-v6-c-modal-box` | `<div>` | Initiates a modal box. **Required** |
873 | `.pf-v6-c-modal-box__close` | `<div>` | Creates a container for the modal box close button. **Required** if there is a close button. |
874 | `.pf-v6-c-button.pf-m-plain` | `<button>` | Initiates a modal box close button. |
875 | `.pf-v6-c-modal-box__header` | `<header>` | Initiates a modal box header. **Required** if using a `.pf-v6-c-modal-box__title`. |
876 | `.pf-v6-c-modal-box__header-main` | `<div>` | Initiates a modal box header main container. **Required** when using a modal header. |
877 | `.pf-v6-c-modal-box__header-help` | `<div>` | Initiates the help button container in the modal box header actions. |
878 | `.pf-v6-c-modal-box__title` | `<h1>`,`<h2>`,`<h3>`,`<h4>`,`<h5>`,`<h6>`, `<div>` | Initiates a modal box title. **Required** if using a modal description. |
879 | `.pf-v6-c-modal-box__title-icon` | `<span>` | Initiates a container for the modal box title icon. |
880 | `.pf-v6-c-modal-box__title-text` | `<span>` | Initiates a container for the modal box title text. |
881 | `.pf-v6-c-modal-box__description` | `<div>` | Initiates a modal box description. |
882 | `.pf-v6-c-modal-box__body` | `<div>` | Initiates a modal box body. |
883 | `.pf-v6-c-modal-box__footer` | `<footer>` | Initiates a modal box footer. |
884 | `.pf-m-sm` | `.pf-v6-c-modal-box` | Modifies for a small modal box width. |
885 | `.pf-m-md` | `.pf-v6-c-modal-box` | Modifies for a medium modal box width. |
886 | `.pf-m-lg` | `.pf-v6-c-modal-box` | Modifies for a large modal box width. |
887 | `.pf-m-align-top` | `.pf-v6-c-modal-box` | Modifies for top alignment. |
888 | `.pf-m-icon` | `.pf-v6-c-modal-box__title` | Modifies the title layout to accommodate an icon. |
889 | `.pf-m-custom` | `.pf-v6-c-modal-box`, `.pf-v6-c-modal-box__title` | Modifies for the custom alert state. |
890 | `.pf-m-info` | `.pf-v6-c-modal-box`, `.pf-v6-c-modal-box__title` | Modifies for the info alert state. |
891 | `.pf-m-success` | `.pf-v6-c-modal-box`, `.pf-v6-c-modal-box__title` | Modifies for the success alert state. |
892 | `.pf-m-warning` | `.pf-v6-c-modal-box`, `.pf-v6-c-modal-box__title` | Modifies for the warning alert state. |
893 | `.pf-m-danger` | `.pf-v6-c-modal-box`, `.pf-v6-c-modal-box__title` | Modifies for the danger alert state. |
894 | `.pf-m-help` | `.pf-v6-c-modal-box__header` | Modifies the modal box header to support the help action |