--- includeMockServer: true title: "Dialogs" description: Show modals and popups on demand icon: "icon-[vaadin--modal-list]" soon: true ---
## Browser native dialogs The simplest approach uses [`hx-confirm`](/reference/attributes/hx-confirm) to trigger a native browser prompt before sending a request. On the client, add `hx-confirm` to any element that makes a request: ```html ``` - [`hx-confirm`](/reference/attributes/hx-confirm)=`"Are you sure?"` shows the browser's built-in confirm dialog. - The AJAX request only fires if the user clicks OK. No extra HTML or CSS required. ## Custom modals htmx makes it straightforward to build modals from scratch. A button loads remote content and appends it to `` as a full-screen overlay. On the client, a button fetches the modal markup: ```html ``` - [`hx-get`](/reference/attributes/hx-get) requests `/modal`. - [`hx-target`](/reference/attributes/hx-target)=`"body"` targets the document body. - [`hx-swap`](/reference/attributes/hx-swap)=[`"beforeend"`](/reference/attributes/hx-swap#beforeend) appends the response as the last child of ``. On the server, respond with the full modal markup. [Hyperscript](https://hyperscript.org) handles the close animation -- adding a `.closing` class, waiting for the CSS transition to finish, then removing the element: ```html