## Dialog Informs users while preserving the current page state. ### Basic usage Dialog pops up a dialog box, and it's quite customizable. :::demo Set the `visible` attribute with a `Boolean`, and Dialog shows when it is `true`. The Dialog has two parts: `body` and `footer`, and the latter requires a `slot` named `footer`. The optional `title` attribute (empty by default) is for defining a title. Finally, this example demonstrates how `before-close` is used. ```html click to open the Dialog This is a message ``` ::: :::tip `before-close` only works when user clicks the close icon or the backdrop. If you have buttons that close the Dialog in the `footer` named slot, you can add what you would do with `before-close` in the buttons' click event handler. ::: ### Customizations The content of Dialog can be anything, even a table or a form. This example shows how to use Element Plus Table and Form with Dialog。 :::demo ```html open a Table nested Dialog open a Form nested Dialog Cancel Confirm ``` ::: ### Nested Dialog If a Dialog is nested in another Dialog, `append-to-body` is required. :::demo Normally we do not recommend using nested Dialog. If you need multiple Dialogs rendered on the page, you can simply flat them so that they're siblings to each other. If you must nest a Dialog inside another Dialog, set `append-to-body` of the nested Dialog to true, and it will append to body instead of its parent node, so both Dialogs can be correctly rendered. ```html ``` ::: ### Centered content Dialog's content can be centered. :::demo Setting `center` to `true` will center dialog's header and footer horizontally. `center` only affects Dialog's header and footer. The body of Dialog can be anything, so sometimes it may not look good when centered. You need to write some CSS if you wish to center the body as well. ```html Click to open the Dialog It should be noted that the content will not be aligned in center by default