Feedback

Popconfirm

A lightweight confirmation popover that appears before a destructive action — a simpler alternative to a full AlertDialog when the context is already clear. Supports async confirm handlers with loading state.

Installation

npx benflux-ui add popconfirm

Controlled open state

const [open, setOpen] = useState(false)

<Popconfirm
  title="Are you sure?"
  open={open}
  onOpenChange={setOpen}
  onConfirm={handleConfirm}
>
  <Button onClick={() => setOpen(true)}>Delete</Button>
</Popconfirm>

Custom icon

import { Trash2 } from "lucide-react"

<Popconfirm
  title="Move to trash?"
  icon={<Trash2 className="h-4 w-4 text-destructive" />}
  okType="danger"
  onConfirm={handleDelete}
>
  <Button>Delete</Button>
</Popconfirm>

Props

PropTypeDefaultDescription
title*ReactNodeConfirmation question shown as the popover heading
descriptionReactNodeAdditional context shown below the title
onConfirm(e?) => void | Promise<void>Called when the user clicks OK. Async functions show a loading spinner.
onCancel(e?) => voidCalled when the user clicks Cancel
okTextReactNode"OK"Confirm button label
cancelTextReactNode"Cancel"Cancel button label
okType"default" | "primary" | "danger" | "ghost""primary"Visual style of the OK button
showCancelbooleantrueShow or hide the cancel button
iconReactNode<AlertCircle />Icon displayed next to the title
placement"top" | "bottom" | "left" | "right" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight""top"Preferred placement of the popover
disabledbooleanfalsePrevents the popover from opening
openbooleanControlled open state
defaultOpenbooleanfalseInitial open state (uncontrolled)
onOpenChange(open: boolean) => voidCalled when the open state changes