Material Design Lite
Sticker sheet
Banner
Bottom sheet
Date picker
Expansion Panel
Image list
Grid list
Menu
Ripple
Select
Stepper
Sort header
Tree
View on Material.io

Dialogs can require an action, communicate information, or help users accomplish a task. There are two types of dialogs: basic and full-screen.

Preview

add
Dialog with hero icon
A dialog is a type of modal window that appears in front of app content to provide critical information, or prompt for a decision to be made.

Installation

To import just the component styles, copy the following into your project’s styles.css file:

/* Core Styles */
@import url('https://rodydavis.github.io/material-design-lite/css/core.css');
/* Material Icons */
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
/* Roboto Font */
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap');
/* Component Styles */
@import url('https://rodydavis.github.io/material-design-lite/css/components/dialog/style.css');

Usage

Start with a dialog or div element and add the dialog class name:

<dialog class="dialog"></dialog>

The dialog class name is implicit when using the dialog element.

Hero Icon (Optional)

add

To add a hero icon to a dialog add a i element with the material-icons class name:

<dialog class="dialog">
  <div class="icon-button">
    <i class="material-icons">add</i>
  </div>
</dialog>

Title (Optional)

Dialog with title

To add a title to a dialog add a div element with the title class name:

<dialog class="dialog">
  <div class="title">Dialog with title</div>
</dialog>

Content (Optional)

A dialog is a type of modal window that appears in front of app content to provide critical information, or prompt for a decision to be made.

To add content to a dialog add a div element with the content class name:

<dialog class="dialog">
  <div class="content">
    A dialog is a type of modal window that appears in front of app content to
    provide critical information, or prompt for a decision to be made.
  </div>
</dialog>

Actions (Optional)

To add actions to a dialog add a div element with the actions class name:

<dialog class="dialog">
  <div class="actions">
    <button class="text">Action 1</button>
    <button class="text">Action 2</button>
  </div>
</dialog>

Display Modes

Static

To have a dialog always be visible, add the open attribute to the dialog element:

<dialog class="dialog" open></dialog>

To have a dialog be modal, add the modal class name to the dialog element:

<dialog class="dialog modal"></dialog>

Then from your JavaScript, call the showModal() method on the dialog element:

const dialog = document.querySelector('dialog');
dialog.showModal();

Variants

Default

Default dialog styling.

add
Dialog with hero icon
A dialog is a type of modal window that appears in front of app content to provide critical information, or prompt for a decision to be made.
<dialog class="dialog" open>
  <div class="icon-button">
    <i class="material-icons">add</i>
  </div>
  <div class="title">Dialog with hero icon</div>
  <div class="content">
    A dialog is a type of modal window that appears in front of app content to
    provide critical information, or prompt for a decision to be made.
  </div>
  <div class="actions">
    <button class="text">Action 1</button>
    <button class="text">Action 2</button>
  </div>
</dialog>

Design Tokens

TokenDescriptionDefault
--md-sys-comp-dialog-background-colorThe background color of the dialog
--md-sys-comp-dialog-colorThe foreground color of the dialog
--md-comp-dialog-container-min-widthThe min width of the container280px
--md-comp-dialog-container-max-widthThe max width of the container560px

Resources

Playground

See the Pen Dialog by Rody Davis (@rodydavis ) on CodePen.