Ant Design Svelte

Popconfirm

Confirmation of actions with cancellation, waiting for a request and repeating after an error.

When to use

Popconfirm asks for confirmation next to the action: delete an entry, undo a change, or perform an irreversible step. The question must describe the consequence. For a large form or a stand-alone task, use Modal; for explanation without solution - Tooltip.

Question, opening and buttons

title asks a question, description — details, children — available trigger-snippet. By default trigger:click, so the native button opens the mouse confirmation, Enter and Space.

Problem Opportunity Example
Get confirmation or cancellation onConfirm, onCancel Main Question
Translate buttons locale, okText, cancelText Signatures
Sometimes skip a question getter/setter bind:open Condition
Perform an asynchronous action Promise from onConfirm Wait and repeat
Change default buttons okButtonProps, cancelButtonProps Button settings

defaultOpen sets the local initial state, bind:open synchronizes it with the application. disabled only disables confirmation: by itself it does not trigger onConfirm. The conditional open example explicitly decides whether to ask a question or perform an action immediately.

Pass text, a number or a Svelte snippet to okText, cancelText or icon. For labels, null and undefined use the locale text, 0 renders as a number, and false and an empty string leave the label empty. For the icon, undefined keeps the default warning, while null, false and an empty string hide it. showCancel controls whether the cancel action is visible.

In the actions example, okType="danger" highlights deletion and okButtonProps.href makes the confirm action a link to the API. Use cancelButtonProps.href for a cancel link. Both links accept target and rel. The type of event.currentTarget is HTMLAnchorElement for a link and HTMLButtonElement for a button.

The native onclick runs before confirmation or cancellation. Calling event.preventDefault() there cancels the action and link navigation. If onclick is omitted, onClick runs after the action starts. The click then bubbles to onPopupClick on the panel root, including the active confirmation in a Tooltip.UniqueProvider. Calling event.stopPropagation() in a child stops the event from bubbling.

The browser follows the link on the original click. While the Promise returned by onConfirm is pending, both links lose their href and Tab skips them.

Promise, error and focus

Synchronous onConfirm closes the surface immediately. The returned Promise holds loading and blocks redo, cancel, escape, and external click until completion. Resolve closes, rejection allows you to repeat the request; onError gives the application the ability to infer the reason.

Do not turn a request failure into a successful row deletion. The application example stores data, error, and operation status separately; a late result must not change an already closed or replaced script.

After normal closing, focus returns to trigger. If the confirmation is removed by the trigger itself, after tick select the next available action. In table example this is the button to restore records.

Position and contents after closing

placement supports twelve directions. arrow can be directed to the center, autoAdjustOverflow adjusts the surface at the edge of the viewport. For touch, leave a clear click action. GetPopupContainer selects a container via Popover rules.

By default, the content is saved after closing. destroyOnHidden removes it; forceRender creates in advance after hydration. fresh updates hidden scalar props, but snippet retains its own Svelte reactivity.

ConfigProvider.popconfirm sets its own trigger/arrow/delay and design defaults; local props take precedence. Semantic title/content refers to the question and description, icon refers to the icon wrapper. styles contains CSS strings; component zIndexPopup is applied through the theme. The full supported popup API is given below.

Inside Tooltip.UniqueProvider, enable unique to open the confirmation in the shared popup. The confirmation keeps its own buttons and handlers. Example with two tooltips and a confirmation.

A non-empty local prefixCls changes the assertion classes. The empty string and undefined inherit ConfigProvider.prefixCls with the -popconfirm suffix, defaulting to ant-popconfirm. The external Popover separately inherits the common prefix with the -popover suffix: the local Popconfirm.prefixCls does not rename it. With suite and local-confirm, the root popup receives both classes: suite-popover and local-confirm. Example ConfigProvider shows priorities and stores confirmation of action.

Popconfirm uses design tokens from the current theme for its appearance.

Examples

No action has been selected yet. onPopupClick × 0

Confirmation and cancellation

Confirm or cancel to change the result. The onPopupClick counter records clicks inside the panel.

Locale and labels

English locale sets OK/Cancel; local texts take precedence.

12 positions

Twelve positions

Basic and angular directions with arrow pointAtCenter.

Confirmed: 0

Automatic offset

Turn on the experience at the bottom edge of the viewport and open the confirmation.

Completed: 0

Conditional opening

bind:open with getter/setter shows a question or immediately performs an action.

Own icon

Decorative SVG via Snippet and disable icon via null.

Successful: 0; errors: 0

Wait for Promise and repeat

Start a query and select its result: success closes, error allows retry.

Buttons and shutdown

A danger action, a confirmation without a cancel button, and a link to the API.

Semantic DOM

The object and function design the container, question, description and icon.

General settings

ConfigProvider.popconfirm and local priority trigger/arrow.

Component token

Local zIndexPopup for Popconfirm.

Removing a participant from a review

Table, query error, repeat and focus change after deleting a row.

API

The table covers the nine examples in ant.design 6.7.2 and the public Svelte API based on 6.6.8. Svelte uses values and snippets for ReactNode content, and CSS strings for CSSProperties. The package contains the complete prop types.

Topics of official examples
ThemeExample
BasicTitle, description, confirmation and cancellation.
Locale textLocale and custom button labels.
Placement12 directions and pointAtCenter.
Auto ShiftReal edge viewport; experience is included separately.
Conditional triggerControlled opening or execution without confirmation.
Customize iconSnippet of the icon and icon=null.
Asynchronously closeIn Svelte, the expectation is set by Promise from onConfirm; manual loading is not transmitted.
Asynchronously close on PromiseSuccess closes the card, error allows replay.
Custom semantic dom stylingContainer, text and icon styling object and function.
Main parameters
PropertyDescriptionTypeDefault
uniqueUses the shared surface of the nearest Tooltip.UniqueProvider.booleanfalse
motionCSS transition name. An empty string disables animation.{ motionName?: string }zoom-big
afterOpenChangeRuns after a standalone popup finishes its transition.(open: boolean) => void—
zIndexSets an explicit layer. Otherwise the popup uses the parent layer when nested.number—
prefixClsFull local CSS confirmation prefix; external Popover separately inherits the common prefix. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-popconfirm.stringConfigProvider + -popconfirm
titleQuestion to the user; an empty header does not open an acknowledgment.string | number | Snippetis required
descriptionConsequences of an action or additional content.string | number | Snippet | null—
iconDecorative icon. Pass null, false or an empty string to hide it.ButtonContentwarning
onConfirmSynchronous action or request. Promise involves waiting.(event: MouseEvent) => void | PromiseLike<unknown>—
onCancelPressing the cancel button. External click and Escape do not trigger this callback.(event: MouseEvent) => void—
onPopupClickReceives the click when it bubbles to the panel root, after the handlers inside the panel run.(event: MouseEvent) => void—
onErrorAction error; the card remains open for replay.(error: unknown) => void—
openSupports bind:open, including getter/setter for conditional open.boolean | undefinedlocal state
defaultOpenInitial visibility of local confirmation.booleanfalse
onOpenChangeChange visibility; During the wait, normal closing is blocked.(open: boolean) => void—
disabledDisables Popconfirm. The accessibility of a child button is set separately.booleancontext / false
okTextConfirm label. Accepts text, a number or a snippet.ButtonContentlocale.popconfirm?.okText ?? locale.okText
cancelTextCancel label. Accepts text, a number or a snippet.ButtonContentlocale.popconfirm?.cancelText ?? locale.cancelText
showCancelVisibility of the cancel button.booleantrue
okTypedanger applies the danger color. The type, danger, color and variant settings in okButtonProps determine the final appearance.ButtonType | 'danger'primary
okButtonPropsAppearance and event handlers for the confirm action. Providing href renders a link.ButtonProps / ButtonLinkProps excluding children, htmlType and loading—
cancelButtonPropsAppearance and event handlers for the cancel action. Providing href renders a link.ButtonProps / ButtonLinkProps excluding children, htmlType and loading—
placementFour main and eight angular directions.PopoverPlacementtop
alignPointAnchors the popup to the pointer coordinates.booleanfalse
arrowVisibility of arrow and pointAtCenter.TooltipArrowtrue
autoAdjustOverflowPosition correction when there is not enough space.boolean | AdjustOverflowtrue
triggerInherited from ConfigProvider.popconfirm; [] leaves software opening.PopoverTrigger | readonly PopoverTrigger[]click
getPopupContainerBrowser-only selection of DOM container.(trigger: HTMLElement) => HTMLElementnative inline / context
destroyOnHiddenRemoves content after closing, preserving the native shell.booleanfalse
freshUpdates hidden scalar payload; Snippet retains its own reactivity.booleanfalse
classNamesSemantic slots classes: object or function with props.PopconfirmSemantic—
stylesCSS strings semantic slots: object or function.PopconfirmSemantic—

ConfigProvider and general popup properties

popconfirm sets its own trigger, arrow, delays and semantic styles; the ConfigProvider.tooltip settings do not apply to it. Local props take priority. The nested provider replaces the entire popconfirm object; undefined inherits from the parent. The button labels and error message are taken from the locale.

bind:ref provides a PopoverRef with nativeElement, popupElement and forceAlign. Examples of container, ref and general surface settings are on the page Popover.

Svelte API differences

Return a Promise from onConfirm to show a pending action. Set button labels with okText and cancelText.

Semantic DOM

Popup has role=dialog, name by title and description by description. During the request, aria-busy appears; Both footer buttons are disabled, and the focus remains inside the card. The action error is output with role=alert. Decorative icon; the question should remain understandable without it.

SlotPurpose
rootpopup surface, position and CSS layer.
containerBackground, padding, radius and shadow.
arrowConfirmation arrow.
titleQuestion text.
contentDescription of action.
iconConfirmation Badge Wrapper.

title and content formulate the question and description within the message. classNames and styles accept an object or function from props. Native popup remains by default next to trigger in DOM and opens in top layer.

Registration tokens

theme.components.Popconfirm sets zIndexPopup; the example uses 1135. Explicit zIndex and semantic styles allow you to refine the layer of an individual instance. Native top layer has its own order of exposed surfaces.

Primary Component Token
TokenPurpose
zIndexPopupCSS confirmation layer; default value is 1060.
Common tokens of the current topic
TokenMeaning
colorTextrgba(0,0,0,0.88)
colorTextHeadingrgba(0,0,0,0.88)
colorWarning#faad14
fontSize14
fontWeightStrong600
marginXS8
marginXXS4

FAQ

How to open confirmation from the keyboard?

Use a native button or Button. The standard click-trigger works with Enter and Space.

Why can't it be closed during a Promise?

Waiting blocks redo and undo. Resolve closes the card, rejection returns the ability to repeat.

How to perform an action without asking a question?

Handle the condition explicitly in the application, such as setter bind:open. disabled itself does not trigger the action.

What to do if trigger is deleted?

After tick, move focus to the next available action. An existing trigger receives focus when closed normally.

Is hidden content updated?

fresh updates scalar props. Snippet remains reactive; destroyOnHidden removes the content.