Dialog
Modal dialog with backdrop, focus trap, Esc-to-close, and focus restore. Slot the body as default content and footer actions into slot="footer".
Preview
The default md dialog (480px). The close button, backdrop click, and Esc all dismiss it.
<button data-target="dlg-md">Open dialog</button>
<esa-dialog id="dlg-md" heading="Medium dialog">
<p>The default md dialog. The close button, backdrop click, and Esc all dismiss it.</p>
<button slot="footer" data-close="dlg-md">Close</button>
</esa-dialog> import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-dialog';
@Component({
selector: 'app-dialog-demo',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<button data-target="dlg-md">Open dialog</button>
<esa-dialog id="dlg-md" heading="Medium dialog">
<p>The default md dialog. The close button, backdrop click, and Esc all dismiss it.</p>
<button slot="footer" data-close="dlg-md">Close</button>
</esa-dialog>
`,
})
export class DialogDemo {} Sizes
Five widths cover compact prompts through immersive, edge-to-edge flows.
The most compact dialog (280px), one step below sm. Tab cycles within; Esc closes.
A compact dialog (360px). Tab cycles within; Esc closes.
The default md dialog (480px).
A large dialog (640px) for richer content.
Edge-to-edge dialog for immersive flows.
<esa-dialog size="xs" heading="Extra small dialog">…</esa-dialog>
<esa-dialog size="sm" heading="Small dialog">…</esa-dialog>
<esa-dialog heading="Medium dialog">…</esa-dialog>
<esa-dialog size="lg" heading="Large dialog">…</esa-dialog>
<esa-dialog size="fullscreen" heading="Fullscreen dialog">…</esa-dialog> import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@esa/ecology/esa-dialog';
@Component({
selector: 'app-dialog-demo',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<esa-dialog size="xs" heading="Extra small dialog">…</esa-dialog>
<esa-dialog size="sm" heading="Small dialog">…</esa-dialog>
<esa-dialog heading="Medium dialog">…</esa-dialog>
<esa-dialog size="lg" heading="Large dialog">…</esa-dialog>
<esa-dialog size="fullscreen" heading="Fullscreen dialog">…</esa-dialog>
`,
})
export class DialogDemo {} API
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Reflected attribute that drives visibility. Set imperatively via show() / close(). |
heading | string | '' | Title shown in the header and used as the dialog accessible name. |
show-close-button | boolean | true | Renders the header close (×) button. Property: `showCloseButton`. On by default. Write `="false"` to turn it off — unusually for a boolean attribute, this one reads the value. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'fullscreen' | 'md' | Panel width: 280 / 360 / 480 / 640px, or edge-to-edge. |
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.
(close)="onClose($event.detail)"
Methods
| Prop | Type | Default | Description |
|---|---|---|---|
show() | method | — | Opens the dialog and traps focus. |
close() | method | — | Closes the dialog, restores focus, and emits the close event. |
Events
| Event | Type | Default | Description |
|---|---|---|---|
close | CustomEvent | — | Fired when the dialog closes (close button, backdrop click, or Esc). Bubbles and is composed. |
Accessibility
- The panel is
role="dialog"witharia-modal="true";headingprovides the accessible name. - Focus is trapped while open — Tab and Shift+Tab cycle within the panel.
- Opening stores the previously focused element and restores it on close.
Escapecloses the dialog; the close button carries anaria-label.
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.
| Role | Re-point | Reach |
|---|---|---|
.typography-body-md |
| +28 more componentsesa-app-shell, esa-breadcrumbs, esa-card, esa-checkbox, esa-checkbox-group, esa-collapsible, esa-combobox, esa-command-palette, esa-confirm-dialog, esa-container, esa-danger-zone, 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 |
| +33 more componentsesa-app-bar, esa-breadcrumbs, esa-button-group, esa-button-toggle, esa-card, esa-checkbox-group, esa-color-picker, esa-combobox, esa-command-palette, esa-confirm-dialog, esa-danger-zone, esa-date-picker, 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 |
| +4 more componentsesa-avatar, esa-confirm-dialog, esa-empty-state, esa-side-dialog |
Wired to this component
No other component reads these — re-point them and esa-dialog is the
only thing that moves.
| Token | Tier | Resolves to |
|---|---|---|
--dialog-width | component | 480px |
--dialog-width-lg | component | 640px |
--dialog-width-sm | component | 360px |
--dialog-width-xs | component | 280px |
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-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-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-secondary | semantic every component | #646464 via --color-gray-11 |
--radius-lg | semantic every component | 0.75rem via --radius-400 |
--radius-md | semantic every component | 0.5rem via --radius-200 |
--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-200 | primitive every component | 0.5rem |
--spacing-300 | primitive every component | 0.75rem |
--spacing-500 | primitive every component | 1.5rem |