Dialog

Informs users while preserving the current page state.

Basic usage

Dialog pops up a dialog box, and it's quite customizable.

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。

Nested Dialog

If a Dialog is nested in another Dialog, append-to-body is required.

Centered content

Dialog's content can be centered.

TIP

The content of Dialog is lazily rendered, which means the default slot is not rendered onto the DOM until it is firstly opened. Therefore, if you need to perform a DOM manipulation or access a component using ref, do it in the open event callback.

Destroy on Close

When this is feature is enabled, the content under default slot will be destroyed with a v-if directive. Enable this when you have perf concerns.

Draggable Dialog

Try to drag the header part.

TIP

When using modal = false, please make sure that append-to-body was set to true, because Dialog was positioned by position: relative, when modal gets removed, Dialog will position itself based on the current position in the DOM, instead of Document.Body, thus the style will be messed up.

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
model-value / v-modelvisibility of Dialogboolean
titletitle of Dialog. Can also be passed with a named slot (see the following table)string
widthwidth of Dialogstring / number50%
fullscreenwhether the Dialog takes up full screenbooleanfalse
topvalue for margin-top of Dialog CSSstring15vh
modalwhether a mask is displayedbooleantrue
append-to-bodywhether to append Dialog itself to body. A nested Dialog should have this attribute set to truebooleanfalse
lock-scrollwhether scroll of body is disabled while Dialog is displayedbooleantrue
custom-classcustom class names for Dialogstring
open-delayTime(milliseconds) before opennumber0
close-delayTime(milliseconds) before closenumber0
close-on-click-modalwhether the Dialog can be closed by clicking the maskbooleantrue
close-on-press-escapewhether the Dialog can be closed by pressing ESCbooleantrue
show-closewhether to show a close buttonbooleantrue
before-closecallback before Dialog closes, and it will prevent Dialog from closingfunction(done),done is used to close the Dialog
draggableenable dragging feature for Dialogbooleanfalse
centerwhether to align the header and footer in centerbooleanfalse
destroy-on-closeDestroy elements in Dialog when closedbooleanfalse

Slots

NameDescription
content of Dialog
titlecontent of the Dialog title
footercontent of the Dialog footer

Events

Event NameDescriptionParameters
opentriggers when the Dialog opens
openedtriggers when the Dialog opening animation ends
closetriggers when the Dialog closes
closedtriggers when the Dialog closing animation ends
open-auto-focustriggers after Dialog opens and content focused
close-auto-focustriggers after Dialog closed and content focused