Dialog

Informs users while preserving the current page state.

Basic usage

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

Set model-value / v-model 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.

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.

Dialog Size

Predefined 5 sizes from 400px (xsmall) to 1040px (xlarge), each size +/- 160px. Or set custom value by width.

Customized Header

The header slot can be used to customize the area where the title is displayed. In order to maintain accessibility, use the title attribute in addition to using this slot, or use the titleId slot property to specify which element should be read out as the dialog title.

Nested Dialog

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

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.

Centered

Dialog's content can be centered.

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.

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.

Note that by enabling this feature, the content will not be rendered before transition.beforeEnter dispatched, there will only be overlay header(if any) footer(if any).

Draggable Dialog

Try to drag the header part. Set draggable to true to drag.

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
sizesize of DialogsizePropsdefault
xsmallsize of Dialogbooleanfalse
smallsize of Dialogbooleanfalse
largesize of Dialogbooleanfalse
xlargesize of Dialogbooleanfalse
widthwidth of Dialogstring / number
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
modal-classcustom class names for Dialog's overlaystring
container-classcustom class names for Dialog's containerstring
header-classcustom class names for Dialog's headerstring
body-classcustom class names for Dialog's bodystring
footer-classcustom class names for Dialog's footerstring
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
scrollableenable scrollable bodybooleanfalse
scrollable-heightscrollable heightstring / number
scrollable-max-heightscrollable max heightstring / number
destroy-on-closeDestroy elements in Dialog when closedbooleanfalse

Slots

NameDescription
content of Dialog
headercontent of the Dialog header; Replacing this removes the title, but does not remove the close button.
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
Last Updated:
Contributors: Tam Mai