Skip to content

Dialog Component

Dialog Component

Dialog component is used to interact with users without leaving the current page, typically used to display important information, request user confirmation, or collect user input, suitable for scenarios that require forcing user attention.

Basic Usage

Basic dialog usage, including title, content, and action button areas.

Show CodeArrow
CopyGitHub

Title Configuration

You can customize the dialog title by setting related attributes, such as adding icons, hiding close buttons, or using custom content.

Show CodeArrow
CopyGitHub

Button Configuration

You can customize the text, type, alignment of bottom buttons, or completely hide the bottom button area.

Show CodeArrow
CopyGitHub

Interaction Methods

Dialog provides various interaction methods and style configuration options, such as hiding the mask layer, disabling default close methods, custom styles, etc.

Show CodeArrow
CopyGitHub

Nested Dialog

You can nest another dialog within a dialog to meet more complex interaction requirements.

Show CodeArrow
CopyGitHub

Draggable Dialog

Set the draggable attribute to true to enable dialog dragging functionality.

Show CodeArrow
CopyGitHub

Event Handling

Dialog component provides rich events for monitoring dialog opening, closing, and interaction states.

Show CodeArrow
CopyGitHub

Dialog API

TDialog Attributes

AttributeDescriptionTypeAccepted ValuesDefault
modelValueWhether to show dialog (two-way binding)booleanfalse
titleDialog titlestring
widthDialog widthstring/number500px
topDialog distance from topstring/number15vh
centerWhether to center title and footerbooleanfalse
append-to-bodyWhether to append to body elementbooleanfalse
close-on-click-modalWhether to close dialog when clicking maskbooleantrue
close-on-press-escapeWhether to close dialog when pressing ESCbooleantrue
show-closeWhether to show close buttonbooleantrue
draggableWhether draggablebooleanfalse
fullscreenWhether to display fullscreenbooleanfalse
before-closeCallback before closingfunction
destroy-on-closeWhether to destroy component when closingbooleanfalse
z-indexDialog z-indexnumber2000
iconTitle iconstring
is-close-iconWhether to show close iconbooleantrue
is-modalWhether to show mask layerbooleantrue
confirm-textConfirm button textstringConfirm
cancel-textCancel button textstringCancel
confirm-typeConfirm button typestringprimary/success/warning/danger/infoprimary
cancel-typeCancel button typestringprimary/success/warning/danger/info
btn-alignButton alignmentstringflex-start/center/flex-endflex-end
is-footWhether to show footer buttonsbooleantrue
paddingPaddingarray[16, 16, 16, 16]
box-shadowShadow settingsarray[0, 2, 12, 'rgba(0, 0, 0, 0.1)']

Events

Event NameDescriptionParameters
openTriggered when dialog opens
openedTriggered when dialog open animation ends
closeTriggered when dialog closes
closedTriggered when dialog close animation ends
confirmTriggered when confirm button is clicked
cancelTriggered when cancel button is clicked
drag-startTriggered when dragging startsevent
dragTriggered during draggingevent
drag-endTriggered when dragging endsevent

Slots

Slot NameDescriptionScope Parameters
defaultDialog content
titleCustom title area content
footerDialog footer operation area content

Methods

Method NameDescriptionParameters
openOpen dialog
closeClose dialog

Style Variables

The dialog component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$bg-color-defaultDefault background color
$bg-color-modelModal background color
$text-color-defaultDefault text color
$border-color-defaultDefault border color
$theme-color-primaryTheme color - Primary
$color-whiteWhite color
$color-blackBlack color
$font-size-defaultDefault font size
$z-index-upUpper layer z-index

Released under the MIT License