Popconfirm
Confirmation of actions with cancellation, waiting for a request and repeating after an error.
When to use
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
Confirmation and cancellation
Confirm or cancel to change the result. The onPopupClick counter records clicks inside the panel.
<script lang="ts">
import { Button, Popconfirm } from '@woodger/antd';
let result = $state(("No action has been selected yet."));
let popupClicks = $state(0);
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 16px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Popconfirm title={("Delete draft?")} description={("This action will require confirmation.")}
okText={("Delete")} cancelText={("Leave")}
onPopupClick={() => { popupClicks += 1; }}
onConfirm={() => { result = ("Deletion confirmed."); }}
onCancel={() => { result = ("Draft saved."); }}>
<Button danger>{("Delete draft")}</Button>
</Popconfirm>
<output aria-label={("Confirmation result")}>{result}</output>
<output aria-label="onPopupClick"><code>onPopupClick</code> × {popupClicks}</output>
</div>
Locale and labels
English locale sets OK/Cancel; local texts take precedence.
<script lang="ts">
import { Button, ConfigProvider, Popconfirm, enUS } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<div class="examples">
<ConfigProvider locale={enUS}>
<Popconfirm title={("Delete the draft?")} description={("Labels come from the English locale.")}>
<Button>English locale</Button>
</Popconfirm>
</ConfigProvider>
<Popconfirm
title={("Delete selected?")}
okText={("Yes, delete")}
cancelText={("No, leave it")}
>
<Button>{("Your labels")}</Button>
</Popconfirm>
</div>
Twelve positions
Basic and angular directions with arrow pointAtCenter.
<script lang="ts">
import { Button, Popconfirm, type PopoverPlacement } from '@woodger/antd';
const positions = [
{ value: 'topLeft', label: 'TL', row: 1, column: 1 },
{ value: 'top', label: 'Top', row: 1, column: 2 },
{ value: 'topRight', label: 'TR', row: 1, column: 3 },
{ value: 'leftTop', label: 'LT', row: 2, column: 1 },
{ value: 'left', label: 'Left', row: 3, column: 1 },
{ value: 'leftBottom', label: 'LB', row: 4, column: 1 },
{ value: 'rightTop', label: 'RT', row: 2, column: 3 },
{ value: 'right', label: 'Right', row: 3, column: 3 },
{ value: 'rightBottom', label: 'RB', row: 4, column: 3 },
{ value: 'bottomLeft', label: 'BL', row: 5, column: 1 },
{ value: 'bottom', label: 'Bottom', row: 5, column: 2 },
{ value: 'bottomRight', label: 'BR', row: 5, column: 3 }
] as const satisfies readonly {
value: PopoverPlacement; label: string; row: number; column: number;
}[];
</script>
<style>
.positions {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
}
.cell {
display: flex;
justify-content: center;
}
.center {
grid-row: 2 / 5;
grid-column: 2;
display: grid;
place-items: center;
text-align: center;
color: var(--ant-color-text-secondary);
}
</style>
<div class="positions">
{#each positions as position (position.value)}
<div
class="cell"
style:grid-row={(position.row)}
style:grid-column={(position.column)}
>
<Popconfirm
title={("Confirm: " + String((position.value)) + "?")}
placement={position.value}
arrow={{ pointAtCenter: true }}
>
<Button aria-label={("Position " + String((position.value)) + "")}>{(position.label)}</Button>
</Popconfirm>
</div>
{/each}
<div class="center">{("12 positions")}</div>
</div>
Automatic offset
Turn on the experience at the bottom edge of the viewport and open the confirmation.
<script lang="ts">
import { Button, Checkbox, Popconfirm } from '@woodger/antd';
let enabled = $state(false);
let confirmed = $state(0);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.edge {
position: fixed;
right: 12px;
bottom: 12px;
z-index: 20;
display: flex;
align-items: center;
gap: 8px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Checkbox
bind:checked={enabled}
>{("Show confirmation at the edge of the screen")}</Checkbox>
<output
aria-label={("Confirmations at the edge")}
>{("Confirmed: ")}{confirmed}</output>
</div>
{#if enabled}
<div class="edge">
<Popconfirm title={("Confirmation at the edge")} description={("The card remains inside the window.")}
placement="bottom" onConfirm={() => { confirmed++; }}>
<Button type="primary">{("At the edge of the window")}</Button>
</Popconfirm>
<Button
aria-label={("Remove the button at the edge")}
onclick={() => { enabled = false; }}
>×</Button>
</div>
{/if}
Conditional opening
bind:open with getter/setter shows a question or immediately performs an action.
<script lang="ts">
import { Button, Checkbox, Popconfirm } from '@woodger/antd';
let needConfirmation = $state(true);
let open = $state(false);
let completed = $state(0);
function perform() {
completed++;
open = false;
}
function requestOpen(next: boolean | undefined) {
if (next && !needConfirmation) {
perform();
return;
}
open = Boolean(next);
}
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 16px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Checkbox bind:checked={needConfirmation}>{("Ask for confirmation")}</Checkbox>
<Popconfirm title={("Perform action?")} bind:open={() => open, requestOpen}
onConfirm={perform}>
<Button>{("Perform action")}</Button>
</Popconfirm>
<output
aria-label={("Actions performed")}
>{("Completed: ")}{completed}</output>
</div>
Own icon
Decorative SVG via Snippet and disable icon via null.
<script lang="ts">
import { Button, Popconfirm } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
{#snippet question()}
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="2" />
<path d="M9.5 9a2.5 2.5 0 0 1 5 0c0 2-2.5 2-2.5 4" stroke="currentColor"
stroke-width="2" stroke-linecap="round" />
<circle cx="12" cy="16.5" r="1" fill="currentColor" />
</svg>
{/snippet}
<div class="examples">
<Popconfirm title={("Continue with selected settings?")} icon={question}
styles={{ icon: 'color: var(--ant-color-primary)' }}>
<Button>{("Own icon")}</Button>
</Popconfirm>
<Popconfirm title={("Confirm without icon?")} icon={null}>
<Button>{("Without icon")}</Button>
</Popconfirm>
</div>
Wait for Promise and repeat
Start a query and select its result: success closes, error allows retry.
<script lang="ts">
import { onDestroy } from 'svelte';
import { Button, Popconfirm } from '@woodger/antd';
let pending = $state<{
resolve: () => void;
reject: (error: Error) => void;
}>();
let completed = $state(0);
let failed = $state(0);
function confirm() {
return new Promise<void>((resolve, reject) => {
pending = { resolve, reject };
});
}
function finish(success: boolean) {
const operation = pending;
if (!operation) {
return;
}
pending = undefined;
if (success) {
completed++;
operation.resolve();
}
else {
operation.reject(new Error(('Demo request failed')));
}
}
onDestroy(() => pending?.resolve());
</script>
<style>
.example, .request {
display: grid;
justify-items: start;
gap: 16px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
p { margin: 0; }
output { color: var(--ant-color-text-secondary); }
</style>
{#snippet description()}
<div class="request">
<p>{("Click Start, then select a query result.")}</p>
<div class="actions">
<Button size="small" disabled={!pending} onclick={() => finish(true)}>
{("\n Complete successfully\n ")}
</Button>
<Button size="small" disabled={!pending} onclick={() => finish(false)}>
{("\n Return error\n ")}
</Button>
</div>
</div>
{/snippet}
<div class="example">
<Popconfirm
title={("Start a request?")}
description={(description)}
okText={("Start")}
onConfirm={confirm}
onError={() => { failed++; }}
>
<Button type="primary">{("Request with Promise")}</Button>
</Popconfirm>
<output
aria-label={("Query results")}
>{("Successful: ")}{completed}{("; errors: ")}{failed}</output>
</div>
Semantic DOM
The object and function design the container, question, description and icon.
<script lang="ts">
import { Button, Popconfirm } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<div class="examples">
<Popconfirm title={("Styles by object")} description={("Text and icon design.")}
classNames={{ root: 'popconfirm-semantic-object' }}
styles={{
container: 'border-radius: 12px',
title: `
font-weight: 600;
color: var(--ant-color-primary);
`,
content: 'padding-top: 8px',
icon: 'color: var(--ant-color-primary)'
}}>
<Button>{("styles object")}</Button>
</Popconfirm>
<Popconfirm title={("Styles function")} description={("The function receives confirmation props.")}
classNames={() => ({ root: 'popconfirm-semantic-function' })}
styles={({ props }) => ({
title: `font-weight: ${props.placement === 'top' ? 700 : 500}`,
container: 'border: 1px solid var(--ant-color-primary-border)'
})}>
<Button>{("Function styles")}</Button>
</Popconfirm>
</div>
General settings
ConfigProvider.popconfirm and local priority trigger/arrow.
<script lang="ts">
import { Button, ConfigProvider, Popconfirm } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<ConfigProvider popconfirm={{ trigger: 'focus', arrow: false }}>
<div class="examples">
<Popconfirm title={("Context settings")}>
<Button>{("General focus")}</Button>
</Popconfirm>
<Popconfirm title={("Local settings")} trigger="click" arrow>
<Button>{("Local push")}</Button>
</Popconfirm>
</div>
</ConfigProvider>
Component token
Local zIndexPopup for Popconfirm.
<script lang="ts">
import { Button, ConfigProvider, Popconfirm } from '@woodger/antd';
</script>
<ConfigProvider theme={{ components: { Popconfirm: { zIndexPopup: 1135 } } }}>
<Popconfirm title={("Local confirmation topic")} description={("Custom CSS layer Popconfirm.")}>
<Button>{("Popconfirm Token")}</Button>
</Popconfirm>
</ConfigProvider>
Member | Role | Actions |
|---|---|---|
| Анна | Разработчик | |
| Михаил | Дизайнер | |
Removing a participant from a review
Table, query error, repeat and focus change after deleting a row.
<script lang="ts">
import { onDestroy, tick } from 'svelte';
import {
Button,
Checkbox,
Popconfirm,
Table,
type PopoverPlacement,
type TableColumn
} from '@woodger/antd';
interface Member {
key: number;
name: string;
role: string;
}
const generatedId = $props.id();
const restoreId = `${generatedId}-restore`;
const initialMembers: Member[] = [
{ key: 1, name: "Anna", role: "Developer" },
{ key: 2, name: "Mikhail", role: "Designer" }
];
let members = $state(initialMembers.map((member) => ({ ...member })));
let failNext = $state(false);
let pending = $state(0);
let result = $state('');
let placement = $state<PopoverPlacement>('top');
let active = true;
const waiters = new Map<ReturnType<typeof setTimeout>, () => void>();
const columns: TableColumn<Member>[] = [
{ key: 'name', title: "Member", dataIndex: 'name' },
{ key: 'role', title: "Role", dataIndex: 'role' },
{ key: 'actions', title: "Actions", render: actions }
];
async function remove(member: Member) {
const shouldFail = failNext;
failNext = false;
pending++;
await new Promise<void>((resolve) => {
const timer = setTimeout(() => {
waiters.delete(timer);
resolve();
}, 600);
waiters.set(timer, resolve);
});
if (!active) {
return;
}
pending--;
if (shouldFail) {
throw new Error(('Demo request failed'));
}
members = members.filter((item) => item.key !== member.key);
result = ("" + String((member.name)) + ": entry deleted.");
await tick();
if (active) {
const restoreButton = document.getElementById(restoreId);
restoreButton?.focus({ preventScroll: true });
}
}
onDestroy(() => {
active = false;
for (const [timer, resolve] of waiters) {
clearTimeout(timer);
resolve();
}
waiters.clear();
});
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 24px;
}
.settings label {
display: flex;
align-items: center;
gap: 8px;
}
select {
padding: 4px 8px;
color: var(--ant-color-text);
background: var(--ant-color-bg-container);
border: 1px solid var(--ant-color-border);
border-radius: 6px;
font: inherit;
}
.footer {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-top: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
{#snippet actions(member: Member)}
<Popconfirm
title={("Delete entry \"" + String((member.name)) + "»?")}
description={("The entry will disappear from the list of participants.")}
okText={("Delete")}
cancelText={("Leave")}
okButtonProps={{ danger: true }}
{placement}
onConfirm={() => remove(member)}
>
<Button
danger
size="small"
aria-label={("Delete: " + String((member.name)) + "")}
>{("Delete")}</Button>
</Popconfirm>
{/snippet}
<div class="settings">
<Checkbox
bind:checked={failNext}
>{("Next deletion will fail")}</Checkbox>
<label>{("Confirmation position ")}<select
bind:value={placement}
><option
value="top"
>{("Top")}</option><option
value="bottom"
>{("Bottom")}</option><option
value="left"
>{("Left")}</option><option
value="right"
>{("Right")}</option></select></label>
</div>
<Table
dataSource={(members)}
columns={(columns)}
pagination={(false)}
caption={("Participants to confirm deletion")}
scroll={{ x: 500 }}
/>
<div class="footer">
<Button
id={restoreId}
disabled={pending > 0}
onclick={() => {
members = initialMembers.map((member) => ({ ...member }));
result = '';
}}
>{("Recover records")}</Button>
<output aria-label={("Result of removal")}>{(result
|| ("Confirm deletion or leave a note."))}</output>
</div>
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.
| Theme | Example |
|---|---|
| Basic | Title, description, confirmation and cancellation. |
| Locale text | Locale and custom button labels. |
| Placement | 12 directions and pointAtCenter. |
| Auto Shift | Real edge viewport; experience is included separately. |
| Conditional trigger | Controlled opening or execution without confirmation. |
| Customize icon | Snippet of the icon and icon=null. |
| Asynchronously close | In Svelte, the expectation is set by Promise from onConfirm; manual loading is not transmitted. |
| Asynchronously close on Promise | Success closes the card, error allows replay. |
| Custom semantic dom styling | Container, text and icon styling object and function. |
| Property | Description | Type | Default |
|---|---|---|---|
unique | Uses the shared surface of the nearest Tooltip.UniqueProvider. | boolean | false |
motion | CSS transition name. An empty string disables animation. | { motionName?: string } | zoom-big |
afterOpenChange | Runs after a standalone popup finishes its transition. | (open: boolean) => void | — |
zIndex | Sets an explicit layer. Otherwise the popup uses the parent layer when nested. | number | — |
prefixCls | Full local CSS confirmation prefix; external Popover separately inherits the common prefix. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-popconfirm. | string | ConfigProvider + -popconfirm |
title | Question to the user; an empty header does not open an acknowledgment. | string | number | Snippet | is required |
description | Consequences of an action or additional content. | string | number | Snippet | null | — |
icon | Decorative icon. Pass null, false or an empty string to hide it. | ButtonContent | warning |
onConfirm | Synchronous action or request. Promise involves waiting. | (event: MouseEvent) => void | PromiseLike<unknown> | — |
onCancel | Pressing the cancel button. External click and Escape do not trigger this callback. | (event: MouseEvent) => void | — |
onPopupClick | Receives the click when it bubbles to the panel root, after the handlers inside the panel run. | (event: MouseEvent) => void | — |
onError | Action error; the card remains open for replay. | (error: unknown) => void | — |
open | Supports bind:open, including getter/setter for conditional open. | boolean | undefined | local state |
defaultOpen | Initial visibility of local confirmation. | boolean | false |
onOpenChange | Change visibility; During the wait, normal closing is blocked. | (open: boolean) => void | — |
disabled | Disables Popconfirm. The accessibility of a child button is set separately. | boolean | context / false |
okText | Confirm label. Accepts text, a number or a snippet. | ButtonContent | locale.popconfirm?.okText ?? locale.okText |
cancelText | Cancel label. Accepts text, a number or a snippet. | ButtonContent | locale.popconfirm?.cancelText ?? locale.cancelText |
showCancel | Visibility of the cancel button. | boolean | true |
okType | danger applies the danger color. The type, danger, color and variant settings in okButtonProps determine the final appearance. | ButtonType | 'danger' | primary |
okButtonProps | Appearance and event handlers for the confirm action. Providing href renders a link. | ButtonProps / ButtonLinkProps excluding children, htmlType and loading | — |
cancelButtonProps | Appearance and event handlers for the cancel action. Providing href renders a link. | ButtonProps / ButtonLinkProps excluding children, htmlType and loading | — |
placement | Four main and eight angular directions. | PopoverPlacement | top |
alignPoint | Anchors the popup to the pointer coordinates. | boolean | false |
arrow | Visibility of arrow and pointAtCenter. | TooltipArrow | true |
autoAdjustOverflow | Position correction when there is not enough space. | boolean | AdjustOverflow | true |
trigger | Inherited from ConfigProvider.popconfirm; [] leaves software opening. | PopoverTrigger | readonly PopoverTrigger[] | click |
getPopupContainer | Browser-only selection of DOM container. | (trigger: HTMLElement) => HTMLElement | native inline / context |
destroyOnHidden | Removes content after closing, preserving the native shell. | boolean | false |
fresh | Updates hidden scalar payload; Snippet retains its own reactivity. | boolean | false |
classNames | Semantic slots classes: object or function with props. | PopconfirmSemantic | — |
styles | CSS 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.
| Slot | Purpose |
|---|---|
root | popup surface, position and CSS layer. |
container | Background, padding, radius and shadow. |
arrow | Confirmation arrow. |
title | Question text. |
content | Description of action. |
icon | Confirmation 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.
| Token | Purpose |
|---|---|
zIndexPopup | CSS confirmation layer; default value is 1060. |
| Token | Meaning |
|---|---|
colorText | rgba(0,0,0,0.88) |
colorTextHeading | rgba(0,0,0,0.88) |
colorWarning | #faad14 |
fontSize | 14 |
fontWeightStrong | 600 |
marginXS | 8 |
marginXXS | 4 |
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.