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.
Custom Size
Use the width and height properties to customize the dialog size.
Custom Colors
Use the backgroundColor, borderColor, and textColor properties to customize the dialog colors.
Disable Overlay Close
Use the closeOnClickModal property to disable closing the dialog by clicking the overlay.
Disable ESC Close
Use the closeOnPressEscape property to disable closing the dialog with the ESC key.
Overflow Control
Use the overflow property to control the overflow behavior of the dialog content.
Custom Header and Footer
Use the header and footer slots to customize the dialog's header and footer.
Event Listening
The dialog provides open and close events to listen for open and close states.
Combined Usage
Finally, combine multiple APIs to create a complete dialog:
API Reference
Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| modelValue | Whether to show the dialog | boolean | — | false |
| title | Dialog title | string | — | '' |
| width | Dialog width | string | number | — | 400 |
| height | Dialog height | string | number | — | 200 |
| closeOnClickModal | Close on overlay click | boolean | — | true |
| closeOnPressEscape | Close on ESC key press | boolean | — | true |
| backgroundColor | Background color | string | — | '' |
| borderColor | Border color | string | — | '' |
| textColor | Text color | string | — | '' |
| overflow | Overflow control | boolean | — | false |
Events
| Event Name | Description | Parameters |
|---|---|---|
| update:modelValue | Dialog visibility state update | value: boolean |
| open | Triggered when dialog opens | — |
| close | Triggered when dialog closes | — |
Slots
| Name | Description |
|---|---|
| default | Dialog body content |
| header | Custom header |
| footer | Custom footer |
Type Definitions
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;
}