It would be useful to have a PopConfirm component for lightweight confirmation interactions.
PopConfirm is commonly used when an action needs confirmation but does not require a full AlertDialog or modal dialog. For example, confirming destructive actions such as deleting an item.
A typical usage could look like:
[ Delete ]
┌──────────────────────────┐
│ Are you sure? │
│ │
│ [Cancel] [Confirm] │
└──────────────────────────┘
Proposed API
The API could be similar to other component libraries:
PopConfirm::new()
.title("Are you sure you want to delete this item?")
.description("This action cannot be undone.")
.confirm_text("Delete")
.cancel_text("Cancel")
.on_confirm(...)
.child(Button::new("delete").label("Delete"))
The exact API can follow the existing Popover and button patterns in gpui-kit.
Why
Currently, developers need to compose Popover and other components themselves to implement this common interaction pattern.
Having a built-in PopConfirm would provide:
- A consistent confirmation UX across applications
- A reusable pattern for destructive or potentially irreversible actions
- Less repetitive application-level code
- Consistent positioning, styling, focus handling, and dismissal behavior
Relationship to AlertDialog
This component would complement AlertDialog rather than replace it:
PopConfirm: lightweight, contextual confirmation anchored to the triggering element
AlertDialog: more prominent modal confirmation for important decisions
A PopConfirm could potentially be implemented on top of the existing Popover component.
It would be useful to have a
PopConfirmcomponent for lightweight confirmation interactions.PopConfirmis commonly used when an action needs confirmation but does not require a fullAlertDialogor modal dialog. For example, confirming destructive actions such as deleting an item.A typical usage could look like:
Proposed API
The API could be similar to other component libraries:
The exact API can follow the existing
Popoverand button patterns ingpui-kit.Why
Currently, developers need to compose
Popoverand other components themselves to implement this common interaction pattern.Having a built-in
PopConfirmwould provide:Relationship to
AlertDialogThis component would complement
AlertDialograther than replace it:PopConfirm: lightweight, contextual confirmation anchored to the triggering elementAlertDialog: more prominent modal confirmation for important decisionsA
PopConfirmcould potentially be implemented on top of the existingPopovercomponent.