ConfirmDialog

Confirm an action in a modal dialog.

A ready-made Dialog with a title, description, and confirm and cancel buttons. It needs a unique id and a PBCProvider (or DialogProvider) higher in the tree. trigger takes the trigger button props, same as Button; without it, open the dialog via open and onOpenChange. onConfirm runs on confirmation, then the dialog closes.

Live example

Delete the file?

This action cannot be undone.

Example controls

Usage

import { ConfirmDialog } from '@prosazhin/pbcomponents';

<ConfirmDialog
  id='delete-project'
  title='Delete the project?'
  description='All files will be removed permanently.'
  color='danger'
  confirmText='Delete'
  cancelText='Cancel'
  onConfirm={() => deleteProject()}
  trigger={{ color: 'danger', theme: 'border', children: 'Delete project' }}
/>;

Component API

PropType / variantsPurposeDefault
idstringUnique dialog identifier.—
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.—
triggerDialogTriggerPropsTrigger button props (same as Button); without it, open the dialog via open.—
classNamestringClass of the root element.—

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