ConfirmPopover

Confirm an action in a popup next to the button.

Wrap the action button in ConfirmPopover — clicking it opens a popup with a question and confirm and cancel buttons next to it. onConfirm runs on confirmation, then the popup closes. color='danger' suits irreversible actions. Use it for lightweight confirmations; when the action needs more attention, use ConfirmDialog.

Live example

Example controls

Usage

import { Button, ConfirmPopover } from '@prosazhin/pbcomponents';

<ConfirmPopover
  title='Delete the file?'
  description='This action cannot be undone.'
  color='danger'
  confirmText='Delete'
  cancelText='Cancel'
  onConfirm={() => deleteFile()}
>
  <Button
    color='danger'
    theme='border'
  >
    Delete
  </Button>
</ConfirmPopover>;

Component API

PropType / variantsPurposeDefault
childrenReactElementTrigger element, usually a Button.—
titleReactNodeConfirmation question or heading.—
descriptionReactNodeExplanation below the heading.—
color'primary' | 'danger'primary · dangerConfirm button color.primary
confirmTextstringConfirm button text.Confirm
cancelTextstringCancel button text.Cancel
onConfirm() => voidCalled on confirm; the popup closes afterwards.—
onCancel() => voidCalled on cancel.—
openbooleanControlled open state.—
defaultOpenbooleanInitial open state when uncontrolled.false
onOpenChange(open: boolean) => voidCalled when the popup opens or closes.—
placementPopoverPlacementtop · top-start · top-end · bottom · bottom-start · bottom-end · left · left-start · left-end · right · right-start · right-endSide and alignment relative to the trigger: top, bottom-start, right-end, etc. The popup flips and shifts when space runs out.bottom-start
portalbooleanRenders the popup into a portal at the end of body.false
classNamestringClass of the root element.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.