Skip to content

Overlays

Modal

Also calleddialogdialog boxpopuppop-uplightbox

A centered window that appears on top of the page and blocks everything behind it until the person responds or dismisses it.

How people describe it

  • “popup with a dark background behind it”
  • “box in the middle of the screen that blocks everything else”
  • “confirmation window with Cancel and OK buttons”
  • “window that appears on top of the page”

Good for

  • Confirming a destructive action
  • Short forms that need full focus
  • Showing a single important message

Don’t mix it up with

  • Slides in from an edge and usually holds more content.

  • Small and anchored to a button; the page stays usable.

  • Appears briefly and doesn't block anything.

What your library calls it

LIBRARYCALLS IT
shadcn/uiDialog (AlertDialog for confirmations)
MUIDialog (Modal is the low-level base)
Chakra UIDialog (v3) / Modal (v2)
MantineModal
Radix UIDialog

Accessibility checklist

  • Trap focus while it is open
  • Close on Esc
  • Return focus to the trigger on close
  • Give it an accessible name (aria-labelledby)

Try it

Closed · Esc or the backdrop closes it

Delete this project?

This cannot be undone. Everything inside it will be removed for good.

Focus is trapped inside. Esc, the backdrop, or a button closes it and returns focus.

Prompt

Add a centered modal with title, body, Cancel and Confirm buttons. Trap focus.

~20 estimated prompt tokensDetailed: ~58 estimated prompt tokens

Rough estimate for prompt text only; actual counts vary by model and context.

<dialog id="confirm">
  <h2>Delete project?</h2>
  <p>This can't be undone.</p>
  <form method="dialog">
    <button>Cancel</button>
    <button value="confirm">Delete</button>
  </form>
</dialog>

<button onclick="document.getElementById('confirm').showModal()">Delete</button>

Used in

Explore website blueprints that use this component.