Skip to content

Popconfirm ​

A confirm popover anchored to a trigger. It is not a modal: no mask by default, and the panel uses the light Dropdown surface. In Chinese this component is 確認浮層.

The panel z-index is 4000, the same as Tooltip and Dropdown. Each nested overlay adds 10. OK and Cancel are 34px tall.

Demos ​

Basic

Click the trigger to toggle. OK emits confirm and closes. Cancel, Escape, and an outside click emit cancel with { reason }. Toggling the trigger does not emit cancel.
Save draft

Placements

top, bottom, left, right, plus -start / -end. The panel flips when it would leave the viewport.
TopBottomLeftRight

Warning and delete

warning and error use a danger OK button and an icon. error is an alertdialog and moves focus to Cancel.
ArchiveDelete

Custom texts

Empty ok-text / cancel-text follow the document language: OK / Cancel, or 確定 / 取消.
Publish

Icon trigger

The trigger can be an icon button. Keep the hit target at least 34px.
···

No cancel

show-cancel="false" leaves only OK. Outside click and Escape still dismiss.
Mark read

Arrow off

show-arrow defaults to true. Set show-arrow="false" to hide the 8px arrow.
No arrow

Controlled

open and show are aliases. update:open and update:show carry the next boolean. mask defaults to false; set it only when you want the 40% dim layer and a scroll lock. Async loading on OK is a follow-up — compose it in the app.
LeaveOpen from outside

Alpine ​

html
<gk-popconfirm title="Save this draft?" content="You can keep editing later.">
  <button type="button">Save draft</button>
</gk-popconfirm>

API ​

Props ​

PropTypeDefault
open / showbooleanfalse
titlestring''
content / messagestring''
placementTooltip placements'top'
trigger'click' | 'manual''click'
type'default' | 'warning' | 'error''default'
ok-textstring'' (OK / 確定)
cancel-textstring'' (Cancel / 取消)
show-cancelbooleantrue
disabledbooleanfalse
show-arrowbooleantrue
maskbooleanfalse

v1 opens on click. trigger="manual" leaves opening to open / show. Hover does not open a confirm.

Slots ​

NameDescription
defaultTrigger
titleTitle
contentSupporting copy
footer / actionReplaces the default OK and Cancel buttons

Events ​

NameDetail
update:open / update:showNext boolean
open / close—
confirmOK clicked. The panel then closes.
cancel{ reason: 'cancel' | 'outside' | 'escape' }

CSS parts ​

trigger, panel, arrow, icon, title, content, footer, ok, cancel, mask.

Accessibility ​

  • The panel is role="dialog". type="error" uses role="alertdialog".
  • aria-modal is true only when mask is set.
  • The title and content are referenced with aria-labelledby and aria-describedby.
  • The trigger gets aria-haspopup="dialog" and aria-expanded.
  • Default confirms focus OK. Warning and error focus Cancel when it is shown.
  • Tab cycles inside the panel. Escape closes only the topmost overlay and restores focus to the trigger.