Skip to main content
Urbicon UI
source

ConfirmDialog

Pre-configured dialog for confirming a single, often destructive action. Replaces window.confirm() with a styleable, focus-trapped modal that supports async onConfirm handlers.

Playground

<script lang="ts">
  import { ConfirmDialog } from '@urbicon-ui/blocks';

  let open = $state(false);
</script>

<ConfirmDialog
  bind:open
  cancelLabel="Cancel"
  confirmLabel="Delete"
  description="This cannot be undone."
  intent="danger"
  title="Delete project?"
/>

01 Examples

Destructive confirmation

<script>
  let confirmOpen = $state(false);
</script>
<Button intent="danger" onclick={() => (confirmOpen = true)}>Delete</Button>
<ConfirmDialog
  bind:open={confirmOpen}
  title="Delete project?"
  description="This cannot be undone."
  intent="danger"
  confirmLabel="Delete"
  onConfirm={() => deleteProject()}
/>

Async onConfirm — auto-loading

When onConfirm returns a promise the dialog disables both buttons, blocks dismissal, shows a spinner on the confirm button, then auto-closes on success. If the promise rejects the dialog stays open and re-enables for a retry — surface the failure via onError.
<ConfirmDialog
  bind:open
  title="Submit report?"
  description="Network call may take a moment."
  intent="primary"
  confirmLabel="Submit"
  onConfirm={async () => { await api.submit(); }}
  onError={() => toaster.danger('Could not submit report')}
/>

02 Customization

intent drives both the dialog accent strip and the confirm-button colour. The neutral intent upgrades the confirm button to primary for visual affordance — override via confirmIntent if your design system needs different tones.

For confirmations with richer markup (a list of consequences, a typed-confirmation field), pass content through the default children snippet — it renders below the description.

ConfirmDialog is a pre-configured Dialog and owns no styles of its own: class, unstyled, slotClasses, and preset are forwarded verbatim to the inner Dialog. slotClasses therefore takes the Dialog slot keys (panel, header, title, body, footer, backdrop, …), and presets are registered under the presets.Dialog key on BlocksProvider — a Dialog preset restyles both components. See Customization.

03 Accessibility

Inherited from Dialog

Focus trap, Escape-to-cancel and backdrop-click-to-cancel all come from the underlying Dialog. While an async onConfirm is pending all three are disabled, so the user cannot navigate away mid-action.

Real buttons

Cancel and confirm are actual <button> elements — keyboard navigation (Tab, Enter, Space) works without extra wiring.

Translatable labels

Default labels resolve via bt('button.confirm') / bt('button.cancel') — translate them through the i18n package, or override per call via confirmLabel / cancelLabel.

04 API Reference

21 props
21 props 1 required
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

7 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { ConfirmDialog } from '@urbicon-ui/blocks';