GUILD OF GLEKS UIv21.14.0

gog-dialog

Dialog

A service-driven modal outlet — mount <gog-dialog /> once and open any component as its body through DialogService. Supports stacking, dragging, a built-in focus trap, and a ready-made confirmation dialog.

Overview

Import DialogComponent and mount <gog-dialog /> once — typically near the root of your app. Every DialogService.open() call renders through that single outlet, so it only needs to exist once no matter how many places call it.

typescript
import { DialogComponent, DialogService } from '@guildofgleks/ui/dialog';

@Component({
  // ...
  imports: [DialogComponent],
})
export class AppComponent {
  // Mount <gog-dialog /> once, near the root of your app.
}

Import the dialog and DialogService from @guildofgleks/ui/dialog, with the confirmation dialog and the dialog tokens. The root package has not exported it since 21.14.0 — in 21.13.0 it still did, deprecated — and that is what lets a dialog opened only behind a lazy route keep its own code out of your app's initial bundle. What it imports from the root does not move: the button, icon and scroll area it renders belong to the root package, and load wherever your first page already loads it. Measured on a fresh app with the table, datepicker, calendar and dialog behind one lazy route: the initial bundle went from 101.2 kB to 88.2 kB, and 27 kB of those components' root dependencies stayed in it.

Basic usage — the library ships a ready-made ConfirmationDialogComponent for confirm/cancel prompts:

<gog-button (gogClick)="openConfirm()">Delete workspace</gog-button>
<gog-dialog />

Examples

Custom content

Any component can be the dialog body. Inject DIALOG_DATA to read the data passed to open(), and DIALOG_REF to close the dialog and resolve afterClosed from inside the body itself.

<gog-button (gogClick)="openCustomContent()">Open custom dialog</gog-button>
<gog-dialog />

Non-closable

closable: false hides the header close button and ignores Escape and backdrop clicks — the only way out is a control inside the body.

<gog-dialog />

Non-modal

modal: false leaves the page behind it scrollable and interactive, and drops the Tab focus trap — useful for a lightweight panel rather than a blocking prompt.

<gog-dialog />

Custom width

width and maxWidth are plain CSS values forwarded to the panel.

<gog-dialog />

Stacked dialogs

Calling open() again from inside a dialog's body stacks a new one on top, each with an increasing z-index — the body component can inject DialogService itself, same as any other consumer.

<gog-dialog />

API Reference

DialogConfig

Passed to DialogService.open(config).

NameTypeDefaultDescription
componentType<unknown>requiredThe component rendered as the dialog body.
titlestringundefinedHeader title. The header renders if either title or closable is set.
dataunknownundefinedPassed to the body component via the DIALOG_DATA injection token.
modalbooleantrueLocks body scroll, traps Tab focus inside the panel, and restores focus to the trigger on close.
closablebooleantrueShows the header close button and enables Escape/backdrop-click to close.
draggablebooleantrueLets the header be dragged to reposition the panel. Only takes effect when a header renders.
closeIconNameGogIconName'close'Icon for the header close button.
closeIconTemplateTemplateRef<unknown> | nullnullReplaces the close button icon entirely.
widthstring'auto'CSS width of the panel.
maxWidthstring'90vw'CSS max-width of the panel.
role'dialog' | 'alertdialog''dialog'ARIA role for the panel. Use 'alertdialog' for confirmation-style prompts.
zIndexnumberauto-incrementing from 1000Backdrop z-index. Dropdowns rendered inside the dialog use zIndex + 10.

DialogService methods

SignatureDescription
open<TResult>(config: DialogConfig): DialogHandle<TResult>Opens a dialog. Returns a handle with close(result?) and an afterClosed promise that resolves once the dialog closes, with whatever value close() was called with.
closeAll(result?: unknown): voidCloses every open dialog, resolving each afterClosed with the same result.

Injection tokens

Used inside the component passed as DialogConfig.component.

TokenDescription
DIALOG_DATA: InjectionToken<unknown>Inject inside the body component to read the data passed to open().
DIALOG_REF: InjectionToken<DialogRef<unknown>>Inject inside the body component to call close(result?) and dismiss the dialog from within.

ConfirmationDialogComponent

A ready-made dialog body for confirm/cancel prompts — pass it as component with a ConfirmDialogData object as data: { title, description, confirmText, cancelText }. It closes itself with true on confirm and false on cancel.

Global Configuration

Set any of these once with provideGogConfig() instead of repeating them on every instance — an instance's own input still wins when it sets one itself. See Global Configuration for the full reference.

  • GOG_CONFIG.labels.closeDialog

Styling Tokens

Every CSS custom property the dialog paints with. Override any of them — on a single instance, a subtree, or a theme — to restyle it. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-dialog-backdrop-bg / -backdrop-blurScrim behind the dialog.
--gog-dialog-bg / -color / -border / -radius / -shadowPanel surface.
--gog-dialog-title-font-size / -title-line-heightThe dialog’s <h2>. New tokens in 21.11.0 and the value is the size it was already rendering — the title had simply been inheriting from the browser rather than reading the type scale, so it was outside a theme’s reach.
--gog-dialog-header-padding / -body-paddingSection padding.
--gog-dialog-close-color / -close-hover-color / -close-hover-bgClose button.
--gog-confirmation-dialog-color / -description-color / -actions-gapConfirmation dialog variant.
--gog-confirmation-dialog-title-font-size / -description-font-size (and their line heights)The title and the description, on the type scale since 21.11.0 rather than inherited. The description is the one that visibly moved: 16px to 14px, a step smaller than it was.
--gog-confirmation-dialog-max-widthThe panel’s cap, in ch since 21.11.0 so raising the font size widens the panel with it. It resolves against .confirm-dialog’s own inherited size, not the description’s — a ch cap always reads the font of the element carrying max-width, never a descendant’s.