Popconfirm Dialog
A popconfirm dialog is a non-modal popover dialog with confirm and cancel buttons. It is anchored to a trigger element and uses role="alertdialog" to announce the urgent confirmation prompt.
Use it for inline confirmations such as delete-item, discard-changes, or remove-permission where a full modal dialog would be too disruptive.
Implementation Notes
- Renders a
<div class="popconfirm-dialog">withrole="alertdialog"andaria-modal="false" titleis required and renders inside<h2 class="popconfirm-dialog-title">- Optional
descriptionrenders inside<p class="popconfirm-dialog-description"> aria-labelledbyreferences the title idaria-describedbyreferences the description id (only when present)confirmLabelandcancelLabelare required- Two
<button type="button">elements:popconfirm-dialog-cancelandpopconfirm-dialog-confirm - The container's
hiddenattribute reflects theopenprop - Consumer is responsible for anchoring the dialog near its trigger and managing focus
Props
open: boolean (default: false) -- whether the dialog is opentitle: string (required) -- dialog headingdescription: string (optional) -- body textconfirmLabel: string (required) -- confirm button textcancelLabel: string (required) -- cancel button textonconfirm/onConfirm: callback (optional)oncancel/onCancel: callback (optional)...restProps: any additional HTML attributes
Usage
<PopconfirmDialog
open={isOpen}
title="Delete this item?"
description="This action cannot be undone."
confirmLabel="Delete"
cancelLabel="Cancel"
onconfirm={handleDelete}
oncancel={handleCancel}
/>
Keyboard Interactions
- Tab / Shift+Tab: Move focus between cancel and confirm buttons
- Enter / Space: Activate the focused button
- Escape: Consumer should close the dialog and call
oncancel
ARIA
role="alertdialog"announces the urgent confirmation promptaria-modal="false"reflects that popconfirm is not a modalaria-labelledbyreferences the title idaria-describedbyreferences the description id (when present)- The container is
hiddenwhenopenis false
When to Use
- Use for inline confirmation of a destructive or non-reversible action.
- Use when the confirmation context is small and tightly coupled to the trigger.
When Not to Use
- Do not use for complex confirmations that need extra fields — use a Dialog or AlertDialog.
- Do not block the entire page — use AlertDialog for fully modal alerts.
Headless
Renders semantic alertdialog markup with no styling. Consumer manages positioning relative to the trigger, focus management, escape handling, and the visual treatment.
Styles
Consumer CSS targets popconfirm-dialog, popconfirm-dialog-title, popconfirm-dialog-description, popconfirm-dialog-cancel, and popconfirm-dialog-confirm. Position the dialog adjacent to the trigger with a callout arrow if appropriate.
Testing
- Verify the component renders a
<div>element with classpopconfirm-dialog - Verify
role="alertdialog"andaria-modal="false"are set - Verify the container is
hiddenwhenopenis false - Verify the title renders as an
<h2>with classpopconfirm-dialog-titleand a stable id - Verify
aria-labelledbyreferences the title id - Verify
aria-describedbyreferences the description id only when description is provided - Verify confirm and cancel buttons render with their labels and
type="button" - Verify confirm and cancel handlers fire on click
Advice
- Designers: Place the dialog near the trigger with a clear callout. Keep
titleshort and the description specific. - Developers: Move focus to the cancel button (or confirm, depending on policy) when the dialog opens. Restore focus to the trigger when it closes.
Related components
dialog— a modal or non-modal dialog windowalert-dialog— a modal dialog for urgent messages requiring user acknowledgmentpopover— a floating content box anchored to a trigger element
References
- WAI-ARIA Alert Dialog Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
- Ant Design Popconfirm: https://ant.design/components/popconfirm