2.15.0
Modals gather information, complete a subtask, or provide additional information without losing the context of an underlying page.
Use when displaying information that does not require a user action, such as a read-only document or a supplemental video.
I am a dismissible modal that displays non-essential information.
I am a dismissible modal that displays non-essential information.
<div class="mds-modal">
<div class="mds-modal__wrapper">
<section role="dialog" aria-labelledby="title-modal-1" class="mds-modal__container" aria-hidden="true">
<div class="mds-modal__inner">
<header class="mds-modal__header">
<div class="mds-modal__actions">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#question-circle">
<title>Help</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#print">
<title>Print</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#remove">
<title>Close</title>
</use>
</svg>
</button>
</div>
<h1 class="mds-modal__title" id="title-modal-1"> Dismissible Modal </h1>
</header>
<div class="mds-modal__content">
<p>I am a dismissible modal that displays non-essential information.</p>
</div>
</div>
</section>
</div>
</div>
remove
, within the header, on the right.remove
.escape
.I am a modal that displays non-essential information and has no title.
I am a modal that displays non-essential information and has no title.
<div class="mds-modal">
<div class="mds-modal__wrapper">
<section role="dialog" aria-labelledby="title-modal-1" class="mds-modal__container" aria-hidden="true">
<div class="mds-modal__inner">
<header class="mds-modal__header mds-modal__header--no-title">
<div class="mds-modal__actions">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#question-circle">
<title>Help</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#print">
<title>Print</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#remove">
<title>Close</title>
</use>
</svg>
</button>
</div>
<h1 class="mds-modal__title" id="title-modal-1"> Dismissible Modal </h1>
</header>
<div class="mds-modal__content">
<p>I am a modal that displays non-essential information and has no title.</p>
</div>
</div>
</section>
</div>
</div>
remove
, within the header, on the right.remove
.escape
.Use when a task must be completed, such as entering data and then saving or confirming.
The user can’t close this modal by clicking outside of it. The user must select one of the button options inside the modal header to close it.
The user can’t close this modal by clicking outside of it. The user must select one of the button options inside the modal header to close it.
<div class="mds-modal">
<div class="mds-modal__wrapper">
<section role="dialog" aria-labelledby="title-modal-1" class="mds-modal__container" aria-hidden="true">
<div class="mds-modal__inner">
<header class="mds-modal__header">
<div class="mds-modal__actions">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#question-circle">
<title>Help</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#print">
<title>Print</title>
</use>
</svg>
</button>
<button class="mds-button " type="button" data-mds-modal-close> Cancel </button>
<button class="mds-button mds-button--primary" type="button"> Save </button>
</div>
<h1 class="mds-modal__title" id="title-modal-1"> Action Required Modal </h1>
</header>
<div class="mds-modal__content">
<p>The user can’t close this modal by clicking outside of it. The user must select one of the button options inside the modal header to close it.</p>
</div>
</div>
</section>
</div>
</div>
escape
or clicking outside the modal.Modals are available at a single size, which uses bolded $mds-font-size-l
(20px) text for the title and medium Buttons.
Modals are available in three predefined widths: mds-modal--width-600px
, mds-modal--width-900px
, and mds-modal--width-1200px
.
I am a 600px wide modal.
I am a 900px wide modal.
I am a 1200px wide modal.
max-width: [pixel value]
and a width: 90%
rule, ensuring modals are responsive on narrow viewports.Predefined widths are a starting point. If requirements call for a different modal width, work with a designer to create custom width styles in your product’s CSS.
[.my-custom-modal-width] .mds-modal__container {
max-width: 1000px;
}
<div class="mds-modal [my-custom-modal-width] mds-modal--open mds-modal--active"> ... </div>
mds-modal__content
element, define typography as custom styles within your product. mds-modal__content
does not include any default font styling..mds-overlay
, which partially blocks out the underlying page to focus attention on the modal content.z-index
value when you compose this component with other layered components, e.g., Dialogs, Tooltips, Popovers or Notifications to meet your product requirements. Use title case for titles. (This means capitalize prepositions and conjunctions of four or more letters and all primary words.)
role=”dialog”
to separate content from the rest of the page.aria-labelledby
attribute in the same element as the dialog
role. This attribute references associated title markup to describe the modal and is the first item read by screen readers. Limit title length and avoid being too descriptive (i.e., “Do you want to save this?”); instead, use the aria-describedby
attribute, mentioned next.aria-describedby
attribute for a more thorough description of the modal. For example, “You have made changes. What would you like to do?”aria-hidden=”true”
attribute if the modal is hidden although present in DOM.
Class
|
Applies to
|
Outcome
|
---|---|---|
|
|
Renders a 600px wide modal. |
|
|
Renders a 900px wide modal. |
|
|
Renders a 1200px wide modal. |
|
|
Invokes overlay and triggers visibility of modal. |
|
|
Starts animation of the modal. |
|
|
Opacity increased to |
|
|
Removes header borders and margins. |