2.0.0
Dialogs elicit a response or reveal critical information without losing the context of the underlying page.
Use to communicate critical information.
<div role="dialog" class="mds-dialog ">
<div class="mds-dialog__message"> You have uploaded an incorrect file type, please only upload .xls files. </div>
<div class="mds-dialog__action-buttons">
<div class="mds-dialog__cancel-resolve-buttons-holder">
<button class="mds-button mds-dialog__cancel-button"> Cancel </button>
</div>
</div>
</div>
escape
key.Use to communicate critical information that presents the user with a choice.
<div role="dialog" class="mds-dialog ">
<div class="mds-dialog__message"> Turning off logic mode will remove all parentheses and change the connection between all widgets back to “and”. Are you sure you want to proceed? </div>
<div class="mds-dialog__action-buttons">
<div class="mds-dialog__cancel-resolve-buttons-holder">
<button class="mds-button mds-dialog__cancel-button"> Cancel </button>
<button class="mds-button mds-dialog__resolve-button mds-button--primary"> Continue </button>
</div>
</div>
</div>
escape
key or by clicking outside of the dialog.<div role="dialog" class="mds-dialog ">
<div class="mds-dialog__message"> Your Workbook contains unsaved data, do you want to save your changes? </div>
<div class="mds-dialog__action-buttons">
<button class="mds-button mds-dialog__reject-button"> Don’t Save </button>
<div class="mds-dialog__cancel-resolve-buttons-holder">
<button class="mds-button mds-dialog__cancel-button"> Cancel </button>
<button class="mds-button mds-dialog__resolve-button mds-button--primary"> Save </button>
</div>
</div>
</div>
Dialogs are available at a single size, which uses $mds-font-size-m
(16px) text for the message and medium Buttons.
Dialogs are available in two predefined widths. The default width is 350px and you can use a modifier class to make the dialog wider (mds-dialog--width-500px
).
<div role="dialog" class="mds-dialog ">
<div class="mds-dialog__message"> Turning off logic mode will remove all parentheses and change the connection between all widgets back to “and”. Are you sure you want to proceed? </div>
<div class="mds-dialog__action-buttons">
<div class="mds-dialog__cancel-resolve-buttons-holder">
<button class="mds-button mds-dialog__cancel-button"> Cancel </button>
<button class="mds-button mds-dialog__resolve-button mds-button--primary"> Continue </button>
</div>
</div>
</div>
Predefined widths are a starting point. If requirements call for a different dialog width, work with a designer to create custom width styles in your product’s CSS.
[.my-custom-dialog-width] {
max-width: 600px;
}
<div class="mds-dialog [my-custom-dialog-width]" role="dialog"> ... </div>
Dialogs will often contain form elements, for example, when allowing a user to name a file they are saving. This example shows how Form markup can be injected in to a dialog. It uses a with primary action dialog, Label, Input, and Checkbox.
<form>
and wrapping all related elements in mds-form__field-group
containers. See the grouping elements guidelines in the Forms composition section for more information.mds-form--medium-layout
modifier class to apply margin-based spacing to all form elements. See the spacing elements guidelines in the Forms composition section for more information.<div role="dialog" class="mds-dialog ">
<div class="mds-dialog__message"> Your Workbook contains unsaved data, do you want to save your changes? </div>
<form class="mds-form mds-form--medium-layout" method="post" action="form/processor">
<div class="mds-form__field-group">
<label class="mds-form__label" for="workbook-name"> Workbook Name </label>
<input class="mds-form__input" type="text" id="workbook-name">
</div>
<div class="mds-form__field-group">
<label class="mds-form__checkbox" for="dialog-checkbox">
<input id="dialog-checkbox" type="checkbox" class="mds-form__checkbox-input" checked />
<span class="mds-form__checkbox-visible-wrap">
<span class="mds-form__checkbox-visual">
<svg class="mds-icon mds-form__checkbox-checked-icon" aria-hidden="true">
<use xlink:href="/icons/mds.svg#check--s">
</use>
</svg>
<svg class="mds-icon mds-form__checkbox-indeterminate-icon" aria-hidden="true">
<use xlink:href="/icons/mds.svg#minus--s">
</use>
</svg>
</span>
<span class="mds-form__checkbox-text"> Save Column Set </span>
</span>
</label>
</div>
</form>
<div class="mds-dialog__action-buttons">
<button class="mds-button mds-dialog__reject-button" type="button"> Don’t Save </button>
<div class="mds-dialog__cancel-resolve-buttons-holder">
<button class="mds-button mds-dialog__cancel-button" type="button"> Cancel </button>
<button class="mds-button mds-dialog__resolve-button mds-button--primary" type="button"> Save </button>
</div>
</div>
</div>
.mds-overlay
) to partially block out the underlying page and focus attention on the dialog contents.z-index
value when you compose this component with other layered components, e.g., Modals, Tooltips, Popovers or Notifications to meet your product requirements. role=”dialog”
in .mds-dialog
element attributes.aria-describedby
attribute with .mds-dialog
..mds-dialog__message
element a unique id
and set it as the .mds-dialog
element’s aria-describedby
attribute. For example:<div role="dialog" class="mds-dialog " aria-describedby="mds-dialog-example--0001">
<div class="mds-dialog__message" id="mds-dialog-example--0001"> You have uploaded an incorrect file type, please only upload .xls files. </div> ...
</div>
tabIndex
status for all elements. Then, remove the page element’s tab group and focus status..mds-dialog
.
Class |
Applies to |
Outcome |
---|---|---|
|
|
Indicates that the dialog is active. |
|
|
Renders a 500px wide dialog. |
|
|
Fades out the |
closing tag.
tab-index
on the page beneath the page overlay.tab-index
for the underlying page contents.Promise
.Resolve
, Reject
, and Cancel
, which are sufficient for mapping the prime, reject and close buttons.Promise
s. You may need to consider writing your own Promise
/ Deferred
solution in plain JavaScript for asynchronous capturing Resolve
, Reject
and Cancel
user actions.mds-dialog--fadeout
class and mds-overlay--fadeout
class will animate the dialog.10ms
), then remove the classes.