Skip to content

Dialog ​

Brief Introduction ​

The dialog component is used to display modal dialogs on a page.
You can use <MYDialog></MYDialog> or <MYDialog /> to implement a dialog.

Basic Usage ​

Use v-model to control the visibility of the dialog.

Code Demo
展开代码

Custom Size ​

Use the width and height properties to customize the dialog size.

Code Demo
展开代码

Custom Colors ​

Use the backgroundColor, borderColor, and textColor properties to customize the dialog colors.

Code Demo
展开代码

Disable Overlay Close ​

Use the closeOnClickModal property to disable closing the dialog by clicking the overlay.

Code Demo
展开代码

Disable ESC Close ​

Use the closeOnPressEscape property to disable closing the dialog with the ESC key.

Code Demo
展开代码

Overflow Control ​

Use the overflow property to control the overflow behavior of the dialog content.

Code Demo
展开代码

Use the header and footer slots to customize the dialog's header and footer.

Code Demo
展开代码

Event Listening ​

The dialog provides open and close events to listen for open and close states.

Code Demo
展开代码

Combined Usage ​

Finally, combine multiple APIs to create a complete dialog:

Code Demo
展开代码

API Reference ​

Props ​

ParameterDescriptionTypeOptionsDefault
modelValueWhether to show the dialogboolean—false
titleDialog titlestring—''
widthDialog widthstring | number—400
heightDialog heightstring | number—200
closeOnClickModalClose on overlay clickboolean—true
closeOnPressEscapeClose on ESC key pressboolean—true
backgroundColorBackground colorstring—''
borderColorBorder colorstring—''
textColorText colorstring—''
overflowOverflow controlboolean—false

Events ​

Event NameDescriptionParameters
update:modelValueDialog visibility state updatevalue: boolean
openTriggered when dialog opens—
closeTriggered when dialog closes—

Slots ​

NameDescription
defaultDialog body content
headerCustom header
footerCustom footer

Type Definitions ​

typescript
interface DialogProps {
  modelValue?: boolean;
  title?: string;
  width?: string | number;
  height?: string | number;
  closeOnClickModal?: boolean;
  closeOnPressEscape?: boolean;
  backgroundColor?: string;
  borderColor?: string;
  textColor?: string;
  overflow?: boolean;
}

interface DialogEmits {
  (e: 'update:modelValue', value: boolean): void;
  (e: 'open'): void;
  (e: 'close'): void;
}

Released under the MIT License.