GitHub

Confirm Dialog

Confirmation modal driven by attributes. Resolves a boolean through confirm / cancel / resolved events. Esc cancels.

Stable wc import '@esa/ecology/esa-confirm-dialog'; Angular usage

Preview

<button data-target="cd-default">Save changes</button>

<esa-confirm-dialog
  id="cd-default"
  heading="Save changes?"
  message="Your changes will be applied immediately."
  confirm-label="Save"
></esa-confirm-dialog>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-confirm-dialog';

@Component({
  selector: 'app-confirm-dialog-demo',
  standalone: true,
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <button data-target="cd-default">Save changes</button>
    <esa-confirm-dialog
      id="cd-default"
      heading="Save changes?"
      message="Your changes will be applied immediately."
      confirm-label="Save"
    ></esa-confirm-dialog>
  `,
})
export class ConfirmDialogDemo {}

Variants

Use warning for reversible-but-risky actions and danger for destructive ones.

<esa-confirm-dialog variant="warning" heading="Unsaved changes"
  message="You have unsaved changes that will be lost." confirm-label="Discard"></esa-confirm-dialog>
<esa-confirm-dialog variant="danger" heading="Delete project?"
  message="This action cannot be undone." confirm-label="Delete"></esa-confirm-dialog>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-confirm-dialog';

@Component({
  selector: 'app-confirm-dialog-demo',
  standalone: true,
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <esa-confirm-dialog
      variant="warning"
      heading="Unsaved changes"
      message="You have unsaved changes that will be lost."
      confirm-label="Discard"
    ></esa-confirm-dialog>
    <esa-confirm-dialog
      variant="danger"
      heading="Delete project?"
      message="This action cannot be undone."
      confirm-label="Delete"
    ></esa-confirm-dialog>
  `,
})
export class ConfirmDialogDemo {}

API

PropTypeDefaultDescription
open boolean false Reflected attribute that drives visibility. Open imperatively via show().
heading string '' Title of the confirmation.
message string '' Supporting body text.
variant 'default' | 'danger' | 'warning' 'default' Icon and confirm-button color theme.
confirm-label string 'Confirm' Label of the confirm button. Property: `confirmLabel`.
cancel-label string 'Cancel' Label of the cancel button. Property: `cancelLabel`.
show-icon boolean true Renders the variant icon above the heading. Property: `showIcon`. On by default. Write `="false"` to turn it off — unusually for a boolean attribute, this one reads the value.
show-close-button boolean true Property: `showCloseButton`. On by default. Write `="false"` to turn it off — unusually for a boolean attribute, this one reads the value.
Binding these events from Angular

Every one of these is a CustomEvent, so the payload is on $event.detail — $event.target.value reads empty, with no error. The names are lowercase and Angular passes them to addEventListener verbatim, so camel-casing one means it never fires.

  • (dismiss)="onDismiss($event.detail)"
  • (resolved)="onResolved($event.detail)"

Methods

PropTypeDefaultDescription
show() method — Opens the dialog and focuses the confirm button.
confirm() method — Resolves true and closes.
cancel() method — Resolves false and closes.

Events

EventTypeDefaultDescription
confirm CustomEvent — Fired when the user confirms.
cancel CustomEvent — Fired when the user cancels (button, backdrop, or Esc).
resolved CustomEvent<{ confirmed: boolean }> — Fired on either outcome with the boolean result.

Accessibility

  • The panel is role="alertdialog" with aria-modal="true"; heading is the accessible name.
  • The confirm button receives focus on open; Tab and Shift+Tab cycle between the two buttons.
  • Escape and backdrop click both resolve as cancel; focus is restored on close.

Theming surface

Every public token this component reads, extracted from its source at build time, split by blast radius: the hooks that belong to this component, then the shared and system tokens it consumes alongside everything else. The Resolves to column walks each token's real lineage — component → semantic → primitive → raw value — so you can see exactly where re-pointing it lands. A spoke re-skins by overriding these in its theme-<slug>.css; component internals are never edited. No hook for what you need? File it with /request-lego.

Type roles it names

This component does not set a size, weight, face or tracking of its own — it names a composite, and the composite carries all five. A composite is a class rather than a token, so none of it appears in the tables below; re-theme text by re-pointing the token family, not by editing the component.

RoleRe-pointReach
.typography-body-md
  • --typography-body-md-font-family 'DM Sans', sans-serif via --typography-font-family-sans → --font-family-dm-sans
  • --typography-body-md-font-size clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem) via --font-size-200
  • --typography-body-md-font-weight 350 via --typography-font-weight-regular → --font-weight-350
  • --typography-body-md-letter-spacing 0.01em via --letter-spacing-default
  • --typography-body-md-line-height 1.6 via --line-height-normal
+28 more components esa-app-shell, esa-breadcrumbs, esa-card, esa-checkbox, esa-checkbox-group, esa-collapsible, esa-combobox, esa-command-palette, esa-container, esa-danger-zone, esa-dialog, esa-dropdown-menu, esa-empty-state, esa-entity-search, esa-form-field, esa-header-nav, esa-input-tag, esa-nav-dropdown, esa-page-header, esa-popover, esa-progress-bar, esa-radio-group, esa-select, esa-side-dialog, esa-snackbar-item, esa-switch-toggle, esa-tab-layout, esa-textarea
.typography-label-md
  • --typography-label-md-font-family 'DM Sans', sans-serif via --typography-font-family-sans → --font-family-dm-sans
  • --typography-label-md-font-size clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem) via --font-size-200
  • --typography-label-md-font-weight 500 via --typography-font-weight-medium → --font-weight-500
  • --typography-label-md-letter-spacing 0.01em via --letter-spacing-default
  • --typography-label-md-line-height 1.6 via --line-height-normal
+33 more components esa-app-bar, esa-breadcrumbs, esa-button-group, esa-button-toggle, esa-card, esa-checkbox-group, esa-color-picker, esa-combobox, esa-command-palette, esa-danger-zone, esa-date-picker, esa-dialog, esa-empty-state, esa-entity-search, esa-file-upload, esa-filter-container, esa-form-field, esa-header-nav, esa-input-tag, esa-link-column, esa-page-header, esa-pillbox, esa-popover, esa-progress-bar, esa-radio-group, esa-range-slider, esa-select, esa-side-dialog, esa-sidebar-nav, esa-stat, esa-text-field, esa-textarea, esa-tooltip
.typography-title
  • --typography-title-font-family 'DM Sans', sans-serif via --typography-font-family-sans → --font-family-dm-sans
  • --typography-title-font-size clamp(1rem, 0.88rem + 0.6vw, 1.25rem) via --font-size-400
  • --typography-title-font-weight 500 via --typography-font-weight-medium → --font-weight-500
  • --typography-title-letter-spacing 0.01em via --letter-spacing-default
  • --typography-title-line-height 1.6 via --line-height-normal
+4 more components esa-avatar, esa-dialog, esa-empty-state, esa-side-dialog

Wired to this component

No other component reads these — re-point them and esa-confirm-dialog is the only thing that moves.

Token Tier Resolves to
--confirm-dialog-width component 360px

Shared tokens it reads

Owned by a family or by the semantic layer. Still overridable — but scope the override (esa-foo { --form-border-color: … }) unless you mean to move everything that reads it. Reach says what else that is.

Token Reach Resolves to
--focus-ring-color component focus ring group · +34 more #3e9b4f via --color-border-default-focus → --color-grass-10
--focus-ring-offset component focus ring group · +31 more 2px
--focus-ring-width component focus ring group · +35 more 2px via --border-width-focus → --border-width-200
--animation-overlay-enter semantic every component 250ms via --duration-250
--border-width-default semantic every component 1px via --border-width-100
--color-background-brand semantic every component #46a758 via --color-grass-9
--color-background-brand-hover semantic every component #3e9b4f via --color-grass-10
--color-background-elevation-floating semantic every component #fcfcfc via --color-gray-1
--color-background-elevation-sunken semantic every component #f0f0f0 via --color-gray-3
--color-background-overlay-backdrop semantic every component rgba(0, 0, 0, 0.5) via --color-black-a-7
--color-background-utility-danger semantic every component #ce2c31 via --color-red-11
--color-background-utility-danger-hover semantic every component #641723 via --color-red-12
--color-background-utility-danger-subtle semantic every component #fffcfc via --color-red-1
--color-background-utility-info-subtle semantic every component #fbfdff via --color-blue-1
--color-background-utility-warning semantic every component #ffc53d via --color-yellow-9
--color-background-utility-warning-hover semantic every component #ffba18 via --color-yellow-10
--color-background-utility-warning-subtle semantic every component #fefdfb via --color-yellow-1
--color-border-default-strong semantic every component #bbbbbb via --color-gray-8
--color-border-default-subtle semantic every component #d9d9d9 via --color-gray-6
--color-content-default semantic every component #202020 via --color-gray-12
--color-content-default-knockout semantic every component #fcfcfc via --color-gray-1
--color-content-default-secondary semantic every component #646464 via --color-gray-11
--color-content-on-utility-danger semantic every component #fcfcfc via --color-gray-1
--color-content-on-utility-warning semantic every component #4f3422 via --color-yellow-12
--color-content-utility-danger semantic every component #ce2c31 via --color-red-11
--color-content-utility-info semantic every component #0d74ce via --color-blue-11
--color-content-utility-warning semantic every component #ab6400 via --color-yellow-11
--radius-lg semantic every component 0.75rem via --radius-400
--radius-md semantic every component 0.5rem via --radius-200
--radius-pill semantic every component 9999px via --radius-full
--transition-fast semantic every component 150ms via --duration-150
--typography-font-family-sans semantic every component 'DM Sans', sans-serif via --font-family-dm-sans
--spacing-150 primitive every component 0.375rem
--spacing-200 primitive every component 0.5rem
--spacing-300 primitive every component 0.75rem
--spacing-400 primitive every component 1rem
--spacing-500 primitive every component 1.5rem