Skip to main content

Popconfirm

Pops a confirmation bubble when an element is clicked, used for a second confirmation before dangerous or important operations. It has role="alertdialog" semantics: it traps focus on open and closes after confirm / cancel or Esc.

Basic usage​

Confirm / cancel / tone types
Confirmed 0 times
import { LhButton, LhPopconfirm } from '@lh-ui/react'

export default function Demo() {
return (
<LhPopconfirm title="Are you sure to perform this action?" onConfirm={() => console.log('confirmed')}>
<LhButton>Confirm</LhButton>
</LhPopconfirm>
)
}

Popconfirm Props​

PropDescriptionTypeOptionsDefault
childrenTrigger nodeReactNode——
titleConfirmation title / questionReactNode——
confirmTextConfirm button textstring—Locale pack popconfirm.confirm
cancelTextCancel button textstring—Locale pack popconfirm.cancel
typeTone type'info' | 'warning' | 'danger'—'warning'
placementPlacementLhPopconfirmPlacementtop / bottom / left / right (with -start / -end)'top'
triggerTrigger methodLhPopconfirmTrigger'hover' | 'click' | 'focus' | 'manual''click'
disabledWhether to disableboolean—false
showIconWhether to show the iconboolean—true
hideCancelWhether to hide the cancel buttonboolean—false
visibleControlled visibilityboolean——
defaultVisibleUncontrolled default visibilityboolean—false
popperClassCustom overlay class namestring——
themeVarsComponent-level theme variablesRecord<string, string>——
sxShorthand layout props (applied to the trigger)SxProps——

Popconfirm events​

EventDescriptionCallback signatureVue equivalent
onConfirmClicking the confirm button() => voidconfirm
onCancelClicking the cancel button or pressing Esc() => voidcancel
onVisibleChangeVisibility change(visible: boolean) => voidupdate:visible
Focus trap and Esc

The overlay always traps focus as an alertdialog; pressing Esc is equivalent to clicking cancel (fires onCancel and closes).

Auto-close after confirmation

Consistent with plus: clicking confirm or cancel fires the callback first and then closes; no manual external collapse is needed.

Styles​

import '@lh-ui/react/style/popconfirm'