Skip to content
BENIBIX Learn

Modal Dialog

Design🖼️ User InterfaceOverlays and Feedback

Also known as Modal, Dialog Box, Modal Window, Lightbox

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

Think of it like

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

Example

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

Why it matters

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

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 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.

Try it

Your files
  • report.pdf
  • notes.txt
  • photo.jpg

Use it for a question that cannot be undone, and almost nothing else.

Open it, then try to press a file behind it. Escape is the way out of any layer.

Common mistake

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

Key takeaways

  1. 1
    Blocks the page. Answer first.
  2. 2
    Short and focused. One task or question.
  3. 3
    Easy to leave. Escape and Cancel.

Compare

Learn it properly