Import the inject-function factory and dialog-host contract types from the published package entrypoint.

dialog.ts
import {
  KUI_DIALOG_CONTEXT,
  KuiButtonDirective,
  KuiDialogContext,
  KuiDialogHost,
  kuiDialog,
} from '@kikita-labs/ui';

// Import runtime styles once, application-wide:
import '@kikita-labs/ui/styles';

Implement KuiDialogHost on your dialog component, inject KUI_DIALOG_CONTEXT to read data and close, then create a typed opener with kuiDialog() and call it with data to open. The returned observable emits the typed result once and completes.

<div class="basic-dialog-example">
  <button kuiButton type="button" (click)="invite()">Invite teammate</button>
  @if (lastResult()) {
    <p class="basic-dialog-example__result">Last result: {{ lastResult() }}</p>
  }
</div>

size selects a panel width preset: auto sizes to content with a 320px minimum, sm is 400px, md is 560px (default), and lg is 720px.

<div class="dialog-sizes-example">
  @for (size of sizes; track size) {
    <button kuiButton type="button" shape="outline" (click)="open(size)">{{ size }}</button>
  }
</div>

kuiConfirm() opens a pre-built confirmation dialog without a custom component. It always sets dismissable: false and closable: false, so the user must pick Confirm or Cancel. It resolves Observable<boolean>.

<div class="dialog-confirm-example">
  <button kuiButton type="button" appearance="danger" (click)="deleteRecord()">
    Delete record
  </button>
  @if (lastResult()) {
    <p class="dialog-confirm-example__result">Last result: {{ lastResult() }}</p>
  }
</div>

API verified against @kikita-labs/ui v1.6.1 public typings.

NameTypeDefaultDescription
kuiDialog(component, config?)(component: Type<TComponent>, config?: Omit<KuiDialogConfig, "data">) => (data: TData) => Observable<TResult | undefined>-Inject-function factory. Call once per injection context to get a typed opener bound to that component.
KuiDialogHost<TResult, TData>interface-Contract your dialog component implements. Requires a dialogContext property injected from KUI_DIALOG_CONTEXT.
KUI_DIALOG_CONTEXTInjectionToken<KuiDialogContext<TResult, TData>>-Injected inside the dialog component to read data and close the dialog.
dialogContext.dataTData-Data passed via the opener call, e.g. openDialog(data).
dialogContext.closableboolean-Mirrors KuiDialogConfig.closable. Informational only -- the container renders .kui-dialog-close itself when true.
dialogContext.appearanceKuiDialogAppearance-Mirrors KuiDialogConfig.appearance, for coloring a custom icon if needed.
dialogContext.close(result?)(result?: TResult) => void-Closes the dialog, optionally emitting a typed result to the opener subscription.
KuiDialogConfig.dataTDataundefinedAvailable on the low-level config type; kuiDialog() passes feature data through the returned opener function instead.
KuiDialogConfig.size'auto' | 'sm' | 'md' | 'lg''md'Panel width preset: auto (min 320px), sm (400px), md (560px), lg (720px).
KuiDialogConfig.appearance'default' | 'danger' | 'warning''default'Colors .kui-dialog-icon via a CSS variable. Has no other visual effect.
KuiDialogConfig.dismissablebooleantrueAllows Escape and backdrop click to close the dialog.
KuiDialogConfig.closablebooleantrueShows the .kui-dialog-close button the container renders automatically, absolutely positioned top-right of the panel.
KuiDialogRef<TResult>class-Return type of kuiDialog(component, config). Calling it with data opens the dialog and returns Observable<TResult | undefined>.
kuiConfirm()() => (config: KuiConfirmConfig) => Observable<boolean>-Inject-function for a pre-built confirmation dialog. No custom component required.
KuiConfirmConfig.titlestringrequiredHeader text.
KuiConfirmConfig.messagestring | undefined-Body text.
KuiConfirmConfig.appearanceKuiDialogAppearance'default'Icon color and button tone.
KuiConfirmConfig.confirmLabelstring'OK'Confirm button label.
KuiConfirmConfig.cancelLabelstring'Cancel'Cancel button label.
.kui-dialog-iconCSS class-Add to an SVG placed before .kui-dialog-title inside .kui-dialog-header. Fixed 20x20px, colored via appearance.
--kui-dialog-bgCSS custom propertyvar(--kui-color-surface-elevated)Panel background color.
--kui-dialog-borderCSS custom propertyvar(--kui-color-border)Panel border color.
--kui-dialog-radiusCSS custom propertyvar(--kui-radius-lg)Panel corner radius.
--kui-dialog-shadowCSS custom propertyvar(--kui-shadow-lg)Panel elevation shadow.
--kui-dialog-backdropCSS custom propertyoklch(0 0 0 / 0.5)Backdrop fill color.

Dialog traps focus and blocks page scroll while open, matching native modal expectations.

  • The panel renders role="dialog" and aria-modal="true" automatically.
  • The panel uses aria-labelledby when .kui-dialog-title exists in your content, and falls back to aria-label="Dialog" otherwise. Always include a .kui-dialog-title heading.
  • Focus is trapped inside the dialog via CDK cdkTrapFocus and returns to the opening element after close.
  • Escape and backdrop click close the dialog by default; set dismissable: false for actions the user must explicitly resolve, as kuiConfirm() does.
  • Page scroll is blocked via the CDK block scroll strategy while any dialog is open.
  • The panel renders .kui-dialog-close itself, top-right of the header, when closable is true (the default); the header reserves space for it automatically. dialogContext.closable is retained for informational use only.