Dialog

Example Code

<!-- For this example, we've defined a global variable '$dialog' pointing to the dialog element. -->

<button class="button" onclick="$dialog.showModal()">
  Open Dialog
</button>

<dialog id="dialog1">
  <header class="dialog-header">
    <h1>Leave Without Saving?</h1>
    <button
      class="close button"
      onclick="$dialog.close()"
    ></button>
  </header>
  <div class="dialog-body">
    <p>
      You have unsaved edits. What would you like to do?
    </p>
  </div>
  <div class="dialog-footer">
    <button
      class="primary red button"
      onclick="$dialog.close()"
    >
      Discard Changes
    </button>
    <button class="button" onclick="$dialog.close()">
      Keep Editing
    </button>
  </div>
</dialog>

Result

Leave Without Saving?

You have unsaved edits. What would you like to do?

Options

Size

A dialog can optionally have a size, which controls the maximum width of the dialog. If the contents of the dialog are small, then the dialog might not take up the whole width it is allowed.

To set the size of a dialog, add one of the following classes:

  • small
  • medium
  • large

If you don't add any of the above, the dialog will be as wide as necessary to fit the content without extending past the edge of the screen.

This is a dialog

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis ultricies lacus sed turpis tincidunt id. Rhoncus mattis rhoncus urna neque viverra justo nec.

Pretium nibh ipsum consequat nisl vel pretium lectus quam. Ac placerat vestibulum lectus mauris ultrices. Elementum sagittis vitae et leo duis ut diam. Odio facilisis mauris sit amet massa. Cras semper auctor neque vitae tempus quam. Cursus metus aliquam eleifend mi in. Fermentum iaculis eu non diam. Diam quam nulla porttitor massa id neque aliquam

Drawer

A dialog can optionally be displayed as a drawer. In this case, it is docked to one side of the screen and takes the whole height (if docked to the side) or width (if docked to the top or bottom).

To turn a dialog into a drawer, add the class drawer, along with the side of the screen the drawer should slide out from. Valid sides are:

  • left
  • right
  • top
  • bottom

Drawers also support the same size classes as normal dialogs.

Account Settings


You've made 4 outbound transfers from this account this month. If you make more than 6 outbound transfers in a calendar month, you will be charged a fee of $5.00 as outlined in savings account fees.