logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Dialog

Dialogs notify users about tasks, conveying important information, prompting decisions, or requiring interaction with multiple tasks.

A Dialog is a type of modal window that appears over app content to present critical information or request a decision. Dialogs block all app functionality when visible and remain on screen until confirmed, dismissed, or a necessary action is completed.
Dialogs are intentionally disruptive and should be used judiciously.

Introduction

Dialogs are created using a set of interconnected components:
  • Dialog: the main component that displays the modal.
  • Dialog Title: a container for the dialog’s title.
  • Dialog Actions: an optional wrapper for the dialog’s buttons.
  • Dialog Content: an optional container for the dialog’s main content.
  • Dialog Content Text: a wrapper for text within <DialogContent />.
  • Slide: an optional Transition that animates the dialog entering from the screen’s edge.
Selected: user02@gmail.com

Basics

import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';

Alerts

Alerts are critical interruptions that require user acknowledgment to address a situation.
Most alerts do not require titles. They concisely present a decision by either:
  • Posing a question (e.g., "Delete this conversation?")
  • Providing a statement tied to the action buttons
Title bar alerts should be reserved for high-risk scenarios, such as potential connectivity loss. Users should understand the options based solely on the title and button text.
If a title is needed:
  • Use a straightforward question or statement with a detailed explanation in the content area, such as "Erase USB storage?".
  • Avoid vague or apologetic phrases, such as "Warning!" or "Are you sure?"

Transitions

You can replace the default transition with another, such as Slide, as shown in the next example.

Form dialogs

Form dialogs enable users to complete form fields within a dialog. For instance, a website might prompt potential subscribers to enter their email address and submit it by clicking "Submit".

Customization

This example demonstrates how to customize the dialog component. Further details can be found in the overrides documentation page.
A close button has been added to the dialog to enhance usability.

Full-screen dialogs

Optional sizes

You can define a dialog’s maximum width using the maxWidth prop alongside the fullWidth boolean. When fullWidth is true, the dialog adjusts according to the maxWidth value.

Responsive full-screen

A dialog can be made responsively full-screen by utilizing useMediaQuery.
import useMediaQuery from '@mui/material/useMediaQuery';

function MyComponent() {
  const theme = useTheme();
  const fullScreen = useMediaQuery(theme.breakpoints.down('md'));

  return <Dialog fullScreen={fullScreen} />;
}

Confirmation dialogs

Confirmation dialogs prompt users to explicitly verify their choice before committing to an action. For example, users may preview multiple ringtones but confirm their selection by clicking "OK".
Selecting "Cancel" in a confirmation dialog aborts the action, discards changes, and closes the dialog.
Interruptions
Phone ringtone

Dione

Default notification ringtone

Tethys

Non-modal dialog

Dialogs can be non-modal, allowing user interaction with the background content. For detailed guidance on modal vs. non-modal dialog usage, refer to the Nielsen Norman Group article.
The example below showcases a persistent cookie banner, a typical use case for non-modal dialogs.

Draggable dialog

A draggable dialog can be created using react-draggable. Pass the imported Draggable component as the PaperComponent of the Dialog component to make the entire dialog draggable.

Scrolling long content

When dialogs exceed the viewport or device height, they become scrollable.
  • scroll=paper: the dialog’s content scrolls within the paper element.
  • scroll=body: the dialog’s content scrolls within the body element.
Explore the example below to understand this behavior:

Performance

Refer to the Modal performance section for guidance.

Limitations

Consult the Modal limitations section for details.

Supplementary projects

For advanced scenarios, you may benefit from the following:

material-ui-confirm

starsnpm downloads
The material-ui-confirm package offers dialogs for confirming user actions, reducing the need for boilerplate code.

Accessibility

See the Modal accessibility section for accessibility guidance.