11# Modal
22
3- ## Composed Modal (DEPRECATED)
4-
53Modal is a composition of several subcomponents:
64
75- [ Modal] ( #modal-1 )
@@ -10,27 +8,22 @@ Modal is a composition of several subcomponents:
108 - [ ModalBody] ( #modalfooter )
119 - [ ModalFooter] ( #modalfooter )
1210
13- ⚠️ ** DEPRECATED:** The flag ` Modal--composed ` — which is currently necessary to
14- distinguish the composed version of Modal from the simple one — is deprecated
15- and will be removed in the next major version: the composed Modal will supersede the
16- [ Simple Modal] ( #simple-modal-deprecated ) variant.
17-
18- ### Modal
11+ ## Modal
1912
2013Modal establishes the layer with backdrop. Under the hood it uses the
2114[ ` <dialog> ` element] [ mdn-dialog ] which provides several accessibility
2215advantages.
2316
2417``` html
25- <dialog id =" example_1" class =" Modal Modal--composed " aria-labelledby =" example_1_title" >
18+ <dialog id =" example_1" class =" Modal" aria-labelledby =" example_1_title" >
2619 <!-- ModalDialog -->
2720</dialog >
2821```
2922
3023👉 Please note the ` aria-labelledby ` attribute is linked to the title inside
3124[ ModalHeader] ( #modalheader ) and provides an accessible name for the dialog.
3225
33- #### Custom Preferred Height
26+ ### Custom Preferred Height
3427
3528By default, Modal expands to fit the height of its content, as long as it fits the viewport (see [ more below] ( #custom-max-height ) ).
3629You can override this behavior by setting a custom preferred height using a custom property:
@@ -43,15 +36,15 @@ This is useful for Modals with dynamic content, e.g. a list of items that can be
4336``` html
4437<dialog
4538 id =" example_1"
46- class =" Modal Modal--composed "
39+ class =" Modal"
4740 aria-labelledby =" example_1_title"
4841 style =" --modal-preferred-height-mobile : 400px ; --modal-preferred-height-tablet : 500px ;"
4942>
5043 <!-- ModalDialog -->
5144</dialog >
5245```
5346
54- #### Custom Max Height
47+ ### Custom Max Height
5548
5649The default maximum height of Modal is:
5750
@@ -61,19 +54,14 @@ The default maximum height of Modal is:
6154You can use the custom property ` --modal-max-height-tablet ` to override the max height on tablet screens and up:
6255
6356``` html
64- <dialog
65- id =" example_1"
66- class =" Modal Modal--composed"
67- aria-labelledby =" example_1_title"
68- style =" --modal-max-height-tablet : 700px "
69- >
57+ <dialog id =" example_1" class =" Modal" aria-labelledby =" example_1_title" style =" --modal-max-height-tablet : 700px " >
7058 <!-- ModalDialog -->
7159</dialog >
7260```
7361
7462👉 Please note the max height on mobile screens is currently not customizable. Let us know if you need this feature! 🙏
7563
76- ### ModalDialog
64+ ## ModalDialog
7765
7866ModalDialog is the actual dialog window, a place for the header, body, and
7967footer of the dialog.
@@ -86,7 +74,7 @@ footer of the dialog.
8674</article >
8775```
8876
89- #### Forms in Modal
77+ ### Forms in Modal
9078
9179Modal can also contain interactive content like forms. For such cases, you may
9280find convenient to use the ` <form> ` element with the attribute
@@ -100,13 +88,13 @@ dialog.
10088</form >
10189```
10290
103- #### Expand on Mobile Screens
91+ ### Expand on Mobile Screens
10492
10593We recommend to expand the dialog on mobile screens using the
10694` ModalDialog--expandOnMobile ` modifier class. If you omit the class, the dialog
10795shrinks to fit the height of its content (if smaller than viewport).
10896
109- ### ModalHeader
97+ ## ModalHeader
11098
11199ModalHeader contains the title of the dialog and the close button.
112100
@@ -133,12 +121,12 @@ ModalHeader contains the title of the dialog and the close button.
133121accessible name for the dialog, e.g. using the ` aria-label ` attribute:
134122
135123``` html
136- <dialog id =" example_1" class =" Modal Modal--composed " aria-label =" Accessible Modal Title" >
124+ <dialog id =" example_1" class =" Modal" aria-label =" Accessible Modal Title" >
137125 <!-- … -->
138126</dialog >
139127```
140128
141- ### ModalBody
129+ ## ModalBody
142130
143131ModalBody holds the actual content of the Modal.
144132
@@ -152,7 +140,7 @@ ModalBody holds the actual content of the Modal.
152140</div >
153141```
154142
155- #### Feature Flag to Enable Extra Padding
143+ ### Feature Flag to Enable Extra Padding
156144
157145⚠️ This feature flag is only temporary and will be removed in version 1. The extra vertical padding will be made default.
158146
@@ -165,7 +153,7 @@ The preferred one is the `body` element because this way it will affect all Moda
165153</body >
166154```
167155
168- ### ModalFooter
156+ ## ModalFooter
169157
170158ModalFooter is the place for actions represented by the Button component.
171159While there always must be a primary Button, secondary actions are optional.
@@ -187,7 +175,7 @@ tab over the interface.
187175</div >
188176```
189177
190- #### Footer Description
178+ ### Footer Description
191179
192180Optionally, you can add a description into the footer:
193181
@@ -200,7 +188,7 @@ Optionally, you can add a description into the footer:
200188</div >
201189```
202190
203- #### Footer Alignment
191+ ### Footer Alignment
204192
205193ModalFooter can be aligned to the right (default), center, or left.
206194These values come from the [ dictionary] [ dictionary-alignment ] .
@@ -210,7 +198,7 @@ Using a corresponding modifier class:
210198- ` ModalFooter--center `
211199- ` ModalFooter--left `
212200
213- ### Opening the Modal
201+ ## Opening the Modal
214202
215203Use our JavaScript plugin to open your Modal, e.g.:
216204
@@ -227,7 +215,7 @@ Use our JavaScript plugin to open your Modal, e.g.:
227215</button >
228216```
229217
230- ### Scrolling Long Content
218+ ## Scrolling Long Content
231219
232220When Modals become too long for the user's viewport or device, they scroll independent of the page itself. By default,
233221ModalBody has ` overflow-y: auto ` applied to it, so it scrolls vertically.
@@ -252,7 +240,7 @@ scrolling, e.g.:
252240</article >
253241```
254242
255- ### Full Example
243+ ## Full Example
256244
257245When you put it all together:
258246
@@ -271,7 +259,7 @@ When you put it all together:
271259<!-- Modal Trigger: end -->
272260
273261<!-- Modal: start -->
274- <dialog id =" example_1" class =" Modal Modal--composed " aria-labelledby =" example_1_title" >
262+ <dialog id =" example_1" class =" Modal" aria-labelledby =" example_1_title" >
275263 <!-- ModalDialog: start -->
276264 <article class =" ModalDialog" >
277265 <!-- ModalHeader: start -->
@@ -334,57 +322,6 @@ When you put it all together:
334322<!-- Modal: end -->
335323```
336324
337- ## Simple Modal (DEPRECATED)
338-
339- A simple version of Modal.
340-
341- ⚠️ ** DEPRECATED:** Simple Modal will be removed in the next major version in favour
342- of the composed Modal above.
343-
344- Example usage:
345-
346- ``` html
347- <button
348- type =" button"
349- class =" Button Button--primary Button--medium"
350- data-toggle =" modal"
351- data-target =" #modal-example-1"
352- aria-controls =" modal-example-1"
353- aria-expanded =" false"
354- >
355- Open Modal
356- </button >
357-
358- <dialog id =" modal-example-1" class =" Modal" >
359- <div class =" Modal__content" >
360- <div class =" Modal__dialog" >
361- <div class =" Modal__header" >
362- <button
363- type =" button"
364- class =" Button Button--tertiary Button--medium Button--square"
365- data-dismiss =" modal"
366- data-target =" #modal-example-1"
367- aria-controls =" modal-example-1"
368- aria-expanded =" false"
369- >
370- <svg class =" Icon" width =" 24" height =" 24" aria-hidden =" true" >
371- <use xlink:href =" /icons/svg/sprite.svg#close" />
372- </svg >
373- <span class =" accessibility-hidden" >Close</span >
374- </button >
375- </div >
376- <div class =" Modal__body" >
377- <p >
378- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia
379- perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis
380- provident unde. Eveniet, iste, molestiae?
381- </p >
382- </div >
383- </div >
384- </div >
385- </dialog >
386- ```
387-
388325## Toggle Attributes
389326
390327Both trigger and close buttons use ` data ` attributes to open and close the Modal.
0 commit comments