Skip to content

Dialog

Flagship dialog solution. Compatible with mainstream interaction standards, it features deep enhancements in drag boundary sense, Focus Trap, and Flagship Glassmorphism, providing ultimate visual and operational continuity for production environments.

Basic Usage

The simplest dialog display. Thanks to the built-in Smart Footer system, the component automatically renders standard operational buttons (Cancel/Confirm) by default, providing an out-of-the-box interactive experience without additional slots.

Basic Interaction

Centered Display

In addition to regular top offset, we provide more flexible viewport alignment strategies. Via the align-center and center attributes, you can achieve vertical centering or fullhorizontal alignment for different business scenarios.

Centered Modes
Fullscreen Display

You can control the horizontal alignment of footer buttons via the footer-align attribute. By default, button groups are right-aligned.

Footer Alignment
Header Alignment
Content Alignment

Premium Features

YH-UI provides rich enhancement configurations, supporting semantic type mapping, atomic loading state feedback, and fully transparent custom rendering controllers.

Semantic Types and Icons
Loading State and Async Control
Render Function Support
Destroy on Close (Performance Optimization)
Mouse Origin Animation

Advanced Interaction Features

YH-UI is dedicated to polishing every pixel of interactive feedback. This includes drag algorithms based on viewport physical safety boundaries and flagship-level glassmorphism visual rendering.

Top Interaction Enhancements

Use in Nuxt

Dialog supports Nuxt 3/4 SSR usage. In Nuxt projects, the component can be used directly after normal component registration or auto import setup.

Auto-import

If you are using unplugin-vue-components/resolvers, YhDialog will be automatically loaded on-demand with complete styles.

Nuxt Adaptation
Button Position Swap

Functional Calls

In some scenarios, you may want to skip v-model template declarations and launch a dialog directly via code. YH-UI provides a Promise-based functional call solution, supporting both Hook and static method forms.

Functional Call Demo
Async Feedback and Callbacks
Functional Button Swap

API

Props

PropDescriptionTypeDefault
model-value / v-modelWhether to display the dialogbooleanfalse
titleDialog title, supports string, render function, or componentRenderContent-
typeDialog type'success' | 'warning' | 'error' | 'info' | 'default''default'
show-iconWhether to show semantic iconsbooleantrue
loadingWhether to show body loading statebooleanfalse
contentDialog content, supports string, render function, or componentRenderContent-
actionFooter action area rendered via custom render function or component(() => VNode | Component) | Component-
styleOverall custom stylestring | CSSProperties-
title-classCustom title class namestring-
title-styleCustom title stylestring | CSSProperties-
transform-originAnimation origin position'mouse' | 'center''mouse'
widthDialog widthstring | number'50%'
topDistance from top (effective in non-centered mode)string'15vh'
fullscreenWhether to display in fullscreenbooleanfalse
align-centerWhether to vertically center in the viewportbooleanfalse
centerWhether header, body, and footer are centered togetherbooleanfalse
glassWhether to enable acrylic glass stylebooleanfalse
draggableWhether dragging is enabledbooleanfalse
overflowWhether dragging may move the dialog outside the viewportbooleanfalse
modalWhether to render the backdrop maskbooleantrue
lock-scrollWhether to lock viewport scrolling while openbooleantrue
close-on-click-modalWhether clicking the backdrop closes the dialogbooleantrue
close-on-press-escapeWhether pressing Escape closes the dialogbooleantrue
show-closeWhether to show the close buttonbooleantrue
close-iconCustom close icon namestring'close'
destroy-on-closeWhether body slot content is destroyed after closebooleanfalse
show-footerWhether to render the built-in footer buttonsbooleantrue
cancel-textCustom cancel button text. Falls back to locale text when emptystring''
confirm-textCustom confirm button text. Falls back to locale text when emptystring''
content-classCustom body class namestring-
content-styleCustom body stylestring | CSSProperties-
action-classCustom footer class namestring-
action-styleCustom footer stylestring | CSSProperties-
modal-classCustom background shield class namestring-
custom-classCustom root container class namestring-
z-indexBase layer stack startnumber2000
auto-focusWhether to auto-focus the first focusable elementbooleantrue
before-closeHook before closing(done: () => void) => void-
teleport-toTarget DOM node to mount onstring | HTMLElement'body'
header-align-centerLegacy centered header switchbooleanfalse
header-alignTitle alignment'left' | 'center' | 'right''left'
content-alignContent alignment'left' | 'center' | 'right''left'
footer-align-centerLegacy centered footer switchbooleanfalse
footer-alignFooter button alignment'left' | 'center' | 'right''right'
swap-footer-buttonsWhether to swap the position of "Confirm" and "Cancel" buttonsbooleanfalse
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Slots

Slot NameDescription
defaultDialog body content area
headerCustom header area. If used, the title attribute is ignored
titlePublic type export includes title, but the runtime header entry point is the header slot
footerCustom bottom operational area. If used, built-in buttons are ignored

Events

Event NameDescriptionCallback Parameters
update:modelValueTriggered on visibility state change(value: boolean)
openTriggered when visibility state becomes true-
openedTriggered when opening animation finishes-
closeTriggered when visibility state becomes false-
closedTriggered when closing animation finishes and content is destroyed-
confirmTriggered when default footer "Confirm" button is clicked-
cancelTriggered when default footer "Cancel" button is clicked-
dragStartTriggered when clicking header to start drag(e: MouseEvent)
dragMoveTriggered continuously during dragging(e: MouseEvent)
dragEndTriggered when dragging ends(e: MouseEvent)

Expose

NameDescriptionType
visibleReactive visibility stateRef<boolean>
dialogRefDialog DOM referenceRef<HTMLElement | null>
handleCloseExecutes close logic (triggers before-close)() => void
handleCancelExecutes cancel logic (triggers cancel event and closes)() => void
handleConfirmExecutes confirm logic (triggers confirm event and closes)() => void

Theme Variables

Dialog accepts themeOverrides and mainly consumes shared theme tokens plus a small set of dialog-specific layout tokens from source styles.

VariableDefault ValueDescription
--yh-dialog-margin-top15vhDialog top margin
--yh-bg-color-overlay#ffffffDialog background color
--yh-radius-lg16pxDialog corner radius
--yh-text-color-primary#1a1a1aTitle color
--yh-color-success#67c23aSuccess icon/button color
--yh-color-warning#e6a23cWarning icon/button color
--yh-color-danger#f56c6cError icon/button color
--yh-color-info#909399Info icon/button color
--yh-text-color-secondary#909399Close button color
--yh-text-color-regular#4a4a4aBody text color
--yh-border-color-lightrgba(0,0,0,0.05)Close button hover background

Type Exports

NameDescription
YhDialogPropsProps type for YhDialog
YhDialogEmitsEmits type for YhDialog
YhDialogSlotsSlots type for YhDialog
YhDialogExposeExpose type for YhDialog
YhDialogMethodFunctional dialog method type
YhDialogInstancePublic instance type for YhDialog

Released under the MIT License.