Popconfirm
Popconfirm asks for confirmation around a risky inline action.
@duskmoon-dev/components/popconfirmUsage
When to use
- Use it immediately after user actions or system checks that need visible confirmation.
- Choose the least interruptive feedback surface that still makes the state clear.
Implementation notes
Features
Covers transient, inline, or blocking feedback patterns for user actions and system status.
Shows how the component keeps next actions visible after success, warning, or failure states.
Popconfirm is most often configured through `title`, `description`, `placement`, `trigger`.
Preserves Fragment trigger clicks without invalid Fragment props
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Choose whether the next simulated request succeeds.
Confirmed: 0 · Canceled: 0
Async confirmation and retry
A real button opens native Popconfirm. Reject the next simulated request to keep the confirmation available, then retry successfully or cancel. Pending controls and outcome counters use actual callbacks.
Source
import React, { useEffect, useRef, useState } from "react";
import "@duskmoon-dev/components/styles.css";
import { Popconfirm } from "@duskmoon-dev/components/popconfirm";
export function PopconfirmAsyncPreview() {
const [shouldReject, setShouldReject] = useState(false);
const [pending, setPending] = useState(false);
const [confirmed, setConfirmed] = useState(0);
const [canceled, setCanceled] = useState(0);
const [status, setStatus] = useState("Choose whether the next simulated request succeeds.");
const timerRef = useRef<number | undefined>(undefined);
useEffect(() => () => window.clearTimeout(timerRef.current), []);
async function confirm() {
setPending(true);
setStatus("Confirming deletion…");
try {
await new Promise<void>((resolve) => {
timerRef.current = window.setTimeout(resolve, 300);
});
if (shouldReject) {
setShouldReject(false);
setStatus("Request rejected. The confirmation remains available; retry or cancel.");
throw new Error("Simulated request rejection");
}
setConfirmed((count) => count + 1);
setStatus("Deletion confirmed.");
} finally {
setPending(false);
}
}
return <div data-overlay-confirm-demo style={{ display: "grid", gap: "0.75rem", justifyItems: "start" }}>
<label style={{ display: "flex", alignItems: "center", gap: "0.5rem" }}>
<input className="checkbox" type="checkbox" checked={shouldReject} disabled={pending} onChange={(event) => setShouldReject(event.currentTarget.checked)} />
Reject next request
</label>
<Popconfirm
title="Delete this draft?"
description="A simulated request takes a moment. A rejection keeps these actions available."
placement="bottom"
okText="Delete draft"
cancelText="Keep draft"
cancelButtonProps={{ disabled: pending }}
onConfirm={confirm}
onCancel={() => { setCanceled((count) => count + 1); setStatus("Deletion canceled."); }}
>
<button className="btn btn-outlined" type="button">Review draft deletion</button>
</Popconfirm>
<p role="status" aria-atomic="true">{status}</p>
<p>Confirmed: {confirmed} · Canceled: {canceled}</p>
</div>;
}API
The API reference below lists every parsed exported type or interface for Popconfirm. Start with `title`, `description`, `placement`, `trigger` for common usage.
packages/components/src/components/popconfirm/Popconfirm.types.tsScenarios: packages/components/src/components/popconfirm/Popconfirm.test.tsx| Prop | Type | Required | Description |
|---|---|---|---|
title | ReactNode | No | title configures Popconfirm. |
description | ReactNode | No | description configures Popconfirm. |
placement | PopconfirmPlacement | No | placement configures Popconfirm. |
trigger | PopconfirmTrigger | PopconfirmTrigger[] | No | trigger configures Popconfirm. |
icon | ReactNode | No | icon configures Popconfirm. |
open | boolean | No | open configures Popconfirm. |
defaultOpen | boolean | No | defaultOpen configures Popconfirm. |
disabled | boolean | No | disabled configures Popconfirm. |
arrow | boolean | No | arrow configures Popconfirm. |
destroyTooltipOnHide | boolean | No | destroyTooltipOnHide configures Popconfirm. |
okText | ReactNode | No | okText configures Popconfirm. |
cancelText | ReactNode | No | cancelText configures Popconfirm. |
okButtonProps | ButtonProps | No | okButtonProps configures Popconfirm. |
cancelButtonProps | ButtonProps | No | cancelButtonProps configures Popconfirm. |
showCancel | boolean | No | showCancel configures Popconfirm. |
onConfirm | (event: MouseEvent<HTMLButtonElement>) => PopconfirmAction | No | onConfirm configures Popconfirm. |
onCancel | (event: MouseEvent<HTMLButtonElement>) => PopconfirmAction | No | onCancel configures Popconfirm. |
onOpenChange | (open: boolean) => void | No | onOpenChange configures Popconfirm. |
children | ReactElement | Yes | children configures Popconfirm. |
Type definition
| "top" | "bottom" | "left" | "right" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom"Type definition
"hover" | "focus" | "click" | "contextMenu" | "contextmenu"Type definition
void | Promise<void> | Promise<unknown> | unknown