Skip to content

Popconfirm

Displays a popover with confirmation content on click. Commonly used for dangerous prompts, important toggles, and other scenarios.

Basic Usage

Configure simple prompt information via title.

Basic Usage

Placement

Supports 12 directions of popup positioning, controlled via the placement prop.

Placement

Custom Configuration

Freely customize button text, type, or hide specific elements.

Custom Configuration

Advanced Features

Includes button position swapping and the optional "don't ask again" state.

Advanced Features

Async Close

Use before-confirm to run async confirmation logic before closing the popup.

Async Interception

Custom Slots

Use title and description slots to customize complex rich text content.

Complex Content Slot

Hide Arrow

Control whether the popover displays the indicator arrow via the show-arrow prop.

Arrow Display

Theme Appearance

Customize popup appearance with CSS variables passed through popper-style.

Theme Customization

Use in Nuxt

YhPopconfirm can be used directly in Nuxt after registering the YH-UI module. The trigger and popup content render as normal component markup, while positioning and interaction run on the client after hydration.

Nuxt Demo

Add the module in nuxt.config.ts:

ts
export default defineNuxtConfig({ modules: ['@yh-ui/nuxt'] })

API

Props

PropDescriptionTypeDefault
titleTitle text.string''
descriptionDescription text.string''
confirm-button-textConfirm button text.string''
cancel-button-textCancel button text.string''
confirm-button-typeConfirm button type.'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info''primary'
cancel-button-typeCancel button type.'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info''default'
iconIcon name.string'warning'
icon-colorIcon color.string'#faad14'
hide-iconWhether to hide the icon.booleanfalse
hide-cancelWhether to hide the cancel button.booleanfalse
offsetPopper offset [skidding, distance].[number, number][0, 12]
placementPopper placement.TooltipPlacement'top'
visibleControlled visibility state.boolean | nullnull
widthPopover width.string | number180
disabledWhether the trigger is disabled.booleanfalse
z-indexPopper z-index.number2000
show-arrowWhether to show the popper arrow.booleantrue
popper-classCustom popper class name.string''
popper-styleCustom popper style.StyleValue{}
teleportedWhether to teleport the popup to body.booleantrue
show-dont-ask-againWhether to show the "don't ask again" checkbox.booleanfalse
dont-ask-again-textCustom text for the "don't ask again" checkbox.string''
swap-buttonsWhether to swap confirm and cancel button positions.booleanfalse
before-confirmHook executed before confirm. Return false or resolve false to block closing.() => boolean | Promise<boolean>null
theme-overridesComponent-level theme overrides.ComponentThemeVarsundefined

Slots

Slot NameDescription
defaultTrigger element.
iconCustom icon content.
titleCustom title content.
descriptionCustom description content.

Events

Event NameDescriptionParameters
confirmTriggered when the confirm button is clicked.(dontAskAgain?: boolean) => void
cancelTriggered when the cancel button is clicked.() => void
update:visibleTriggered when visibility changes.(visible: boolean) => void

Expose

NameDescriptionType
visibleCurrent popup visibility state.Ref<boolean>
toggleManually update the popup visibility state.(val: boolean) => boolean

Theme Variables

YhPopconfirm supports themeOverrides. It also consumes tooltip-related variables through the popup layer.

VariableDefaultDescription
--yh-popconfirm-title#1d1d1fTitle text color
--yh-popconfirm-desc#424245Description text color
--yh-tooltip-bg-colorrgba(255, 255, 255, 0.88)Popover background color
--yh-tooltip-border-colorrgba(0, 0, 0, 0.08)Popover border color

Type Exports

NameDescription
YhPopconfirmPropsComponent props type
YhPopconfirmEmitsComponent emits type
YhPopconfirmSlotsComponent slots type
YhPopconfirmExposeComponent expose type
YhPopconfirmInstanceComponent instance type

Released under the MIT License.