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

YH-UI is perfectly adapted for Nuxt 3. You can use it directly in app.vue or any page.

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

Methods of Use

You can choose the most appropriate method based on business complexity.

Two-way binding via v-model, the most suitable way for Vue 3 design patterns.

Independent Import

Manually import YhDialog in sub-components.

ts
import { YhDialog } from '@yh-ui/components'

API

Props

PropDescriptionTypeDefault
v-modelWhether to display the dialogbooleanfalse
titleDialog title, supports render functionstring | (() => VNode)-
typeDialog type'success' | 'warning' | 'error' | 'info' | 'default''default'
show-iconWhether to show semantic iconsbooleantrue
loadingWhether to show body loading statebooleanfalse
contentDialog content, supports render functionstring | (() => VNode)-
actionBottom operation area content, supports render function(() => VNode)-
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
centerFully Centered Mode: Header, Body, Footer content all horizontally centeredbooleanfalse
glassEnable flagship-level Acrylic (Glass) texturebooleanfalse
draggableWhether to enable physical drag functionalitybooleanfalse
overflowWhether to allow dragging beyond viewport boundariesbooleanfalse
modalWhether to display background shieldbooleantrue
lock-scrollLock viewport scroll when displayedbooleantrue
close-on-click-modalWhether to close when clicking the background shieldbooleantrue
close-on-press-escapeWhether to close when pressing ESC keybooleantrue
show-closeWhether to show close buttonbooleantrue
close-iconCustom close icon namestring'close'
destroy-on-closeWhether to destroy Dialog content on closebooleanfalse
show-footerWhether to show default footer buttonsbooleantrue
cancel-textCancel button textstring'Cancel'
confirm-textConfirm button textstring'Confirm'
before-closeHook before closing, parameter is (done: () => void)Function-
teleport-toTarget DOM node to mount onstring | HTMLElement'body'
header-align-centerWhether dialog title is horizontally centeredbooleanfalse
footer-align-centerWhether dialog footer buttons are horizontally centeredbooleanfalse
styleOverall custom stylestring | CSSProperties-
title-classCustom title class namestring-
title-styleCustom title stylestring | CSSProperties-
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
swap-footer-buttonsWhether to swap the position of "Confirm" and "Cancel" buttonsbooleanfalse
footer-alignFooter button alignment'left' | 'center' | 'right''right'
header-alignTitle alignment'left' | 'center' | 'right''left'
content-alignContent alignment'left' | 'center' | 'right''left'

Slots

Slot NameDescription
defaultDialog body content area
headerCustom header area. If used, the title attribute is ignored
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

MethodDescriptionType
visibleReactive visibility stateRef<boolean>
dialogRefDialog DOM referenceRef<HTMLElement>
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 (CSS Variables)

Customize the global vision of Dialog by overriding the following CSS variables.

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

Released under the MIT License.