# Modal Dialog

> A box on top of the page that blocks the rest until you answer.

**Field:** Design  
**Category:** User Interface  
**Also known as:** Modal, Dialog Box, Modal Window, Lightbox

## Think of it like

It is like a teacher who stops the class. You must answer first. Then the class goes on.

## Definition

A modal dialog is a box that opens on top of the page and blocks it. Nothing behind it can be used until it is dealt with. The page behind is dimmed. It suits a short, focused task or an important question, like Delete this file? It must close with Escape and a clear Close or Cancel button. Overusing modals breaks people's flow.

## Example

Leo presses Delete. A modal asks: Delete 3 photos? with Cancel and Delete buttons. The page behind is greyed out.

## Example code

```html
<dialog id="confirm">
  <p>Delete 3 photos?</p>
  <button>Cancel</button> <button>Delete</button>
</dialog>
```

Open it with showModal(). Then it blocks the page, and the Escape key shuts it.

## Why it matters

It asks for one choice at the right time. So a risky step is not taken by mistake.

## Common mistake

Popping a modal the moment a page loads. People close it without reading.

## Three principles

- **Blocks the page.** Answer first.
- **Short and focused.** One task or question.
- **Easy to leave.** Escape and Cancel.

## Related terms

- [Drawer](https://learn.benibix.com/term/design/drawer)
- [Popover](https://learn.benibix.com/term/design/popover)
- [Alert Banner](https://learn.benibix.com/term/design/alert-banner)
- [Bottom Sheet](https://learn.benibix.com/term/design/bottom-sheet)

## Told apart from

- [Modal Dialog vs Drawer](https://learn.benibix.com/compare/modal-dialog-vs-drawer): A modal sits in the middle and blocks the page until you answer it. A drawer slides in from the edge to hold extra menus or filters, and the page stays close by.

## Taught in

- [Modals, Drawers and Popovers](https://learn.benibix.com/learn/design-user-interface/modals-drawers-and-popovers): UI Components, 10/14

---

Source: https://learn.benibix.com/term/design/modal-dialog
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
