← Back to all elements

The <dialog> Element

The <dialog> element represents a dialog box or other interactive component, such as a dismissible alert, inspector, or sub-window.

When to use it

Use the <dialog> element when you need to create modal windows, pop-ups, or any other kind of interactive overlay that requires user interaction. It's great for things like confirmation dialogs, forms, or important notifications.

Native dialogs handle focus management and keyboard accessibility (like trapping focus and closing with the 'Esc' key) out of the box, which is a huge accessibility win.

Live Demo & Code