Dialog
Typed modal overlay opened imperatively via kuiDialog(), not rendered as a bound component instance. Built on Angular CDK Overlay.
Import the inject-function factory and dialog-host contract types from the published package entrypoint.
import {
KUI_DIALOG_CONTEXT,
KuiButton,
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), lg is 720px, and fullscreen fills the viewport without the panel border, radius or shadow.
<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>Set defaults.dialog once for the application or for a subtree. Each option resolves as local input > defaults.dialog.<option> > built-in default.
import { provideKikitaUi } from '@kikita-labs/ui';
export const appConfig: ApplicationConfig = {
providers: [
provideKikitaUi({
defaults: {
dialog: {
/* options below */
},
},
}),
],
};| Name | Type | Default | Description |
|---|---|---|---|
| closable | boolean | — | Shows the close button in the header. |
| size | 'auto' | 'sm' | 'md' | 'lg' | 'fullscreen' | — | Dialog width preset. |
| appearance | 'default' | 'danger' | 'warning' | — | Visual intent of the dialog. |
| dismissable | boolean | — | Closes the dialog on Escape and on a backdrop click. |
| closeIcon | KuiIconGlyph | — | Icon of the close button. Takes precedence over defaults.icons.close. See Structural Icons. |
Set any of these on the component or an ancestor to restyle one part. Each token is optional: when it is not set, the part uses the role or scale token in the default column.
| Name | Type | Default | Description |
|---|---|---|---|
| --kui-dialog-color | CSS custom property | --kui-color-text | Color |
| --kui-dialog-header-border | CSS custom property | --kui-color-border | Header border color |
| --kui-dialog-title-color | CSS custom property | --kui-color-text | Title color |
| --kui-dialog-close-color | CSS custom property | --kui-color-text-secondary | Close color |
| --kui-dialog-close-bg-hover | CSS custom property | --kui-color-state-hover | Close background, hover |
| --kui-dialog-close-color-hover | CSS custom property | --kui-color-text | Close color, hover |
| --kui-dialog-body-color | CSS custom property | --kui-color-text | Body color |
| --kui-dialog-footer-border | CSS custom property | --kui-color-border | Footer border color |
| Name | Type | Default | Description |
|---|---|---|---|
| --kui-dialog-header-gap | CSS custom property | --kui-space-3 | Header gap |
| --kui-dialog-close-radius | CSS custom property | --kui-radius-sm | Close corner radius |
| --kui-dialog-body-font-size | CSS custom property | --kui-text-sm-size | Body font size |
| --kui-dialog-footer-gap | CSS custom property | --kui-space-2 | Footer gap |
| --kui-dialog-min-width-auto | CSS custom property | 320px | Minimum width of the auto-sized dialog |
| --kui-dialog-icon-size | CSS custom property | 20px | Header icon slot size |
| --kui-dialog-close-size | CSS custom property | 28px | Close button size |
Every text the component owns (accessible names, visible words, announcements) is a typed message with an English default. Override it for the application with provideKikitaUi({ messages }), or for a subtree with provideKuiMessages.
| Name | Type | Default | Description |
|---|---|---|---|
| label | string | — | Accessible name of a dialog that has no title. Default Dialog. |
| confirm | string | — | Confirm button of kuiConfirm. Default OK. |
| cancel | string | — | Cancel button of kuiConfirm. Default Cancel. |
API verified against @kikita-labs/ui v2.0.0 public typings.
| Name | Type | Default | Description |
|---|---|---|---|
| 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_CONTEXT | InjectionToken<KuiDialogContext<TResult, TData>> | - | Injected inside the dialog component to read data and close the dialog. |
| dialogContext.data | TData | - | Data passed via the opener call, e.g. openDialog(data). |
| dialogContext.closable | boolean | - | Mirrors KuiDialogConfig.closable. Informational only -- the container renders .kui-dialog-close itself when true. |
| dialogContext.appearance | KuiDialogAppearance | - | 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.data | TData | undefined | Available on the low-level config type; kuiDialog() passes feature data through the returned opener function instead. |
| KuiDialogConfig.size | 'auto' | 'sm' | 'md' | 'lg' | 'fullscreen' | 'md' | Panel width preset: auto (min 320px), sm (400px), md (560px), lg (720px), fullscreen (fills the viewport, no border, radius or shadow). Falls back to defaults.dialog.size. |
| KuiDialogConfig.appearance | 'default' | 'danger' | 'warning' | 'default' | Colors .kui-dialog-icon via a CSS variable. Has no other visual effect. Falls back to defaults.dialog.appearance. |
| KuiDialogConfig.dismissable | boolean | true | Allows Escape and backdrop click to close the dialog. Falls back to defaults.dialog.dismissable. |
| KuiDialogConfig.closable | boolean | true | Shows 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.title | string | required | Header text. |
| KuiConfirmConfig.message | string | undefined | - | Body text. |
| KuiConfirmConfig.appearance | KuiDialogAppearance | 'default' | Icon color and button tone. |
| KuiConfirmConfig.confirmLabel | string | undefined | dialog.confirm message | Confirm button label. Defaults to the dialog.confirm message (OK). |
| KuiConfirmConfig.cancelLabel | string | undefined | dialog.cancel message | Cancel button label. Defaults to the dialog.cancel message (Cancel). |
| .kui-dialog-icon | CSS class | - | Add to an SVG placed before .kui-dialog-title inside .kui-dialog-header. Fixed 20x20px, colored via appearance. |
| --kui-dialog-bg | CSS custom property | var(--kui-color-surface-elevated) | Panel background color. |
| --kui-dialog-border | CSS custom property | var(--kui-color-border) | Panel border color. |
| --kui-dialog-radius | CSS custom property | var(--kui-radius-lg) | Panel corner radius. |
| --kui-dialog-shadow | CSS custom property | var(--kui-shadow-lg) | Panel elevation shadow. |
| --kui-dialog-backdrop | CSS custom property | oklch(0 0 0 / 0.5) | Backdrop fill color. |
| KuiDialogOptions / KuiModalSurfaceOptions | interfaces | - | Shape of defaults.dialog (closable, size, appearance, dismissable, closeIcon), built on the base interface shared with the drawer. Options are read each time a dialog opens, so an open dialog keeps what it opened with. |
Dialog traps focus and blocks page scroll while open, matching native modal expectations.
- The panel renders
role="dialog"andaria-modal="true"automatically. - The panel uses
aria-labelledbywhen.kui-dialog-titleexists in your content, and falls back toaria-label="Dialog"otherwise. Always include a.kui-dialog-titleheading. - Focus is trapped inside the dialog via CDK
cdkTrapFocusand returns to the opening element after close. - Escape and backdrop click close the dialog by default; set
dismissable: falsefor actions the user must explicitly resolve, askuiConfirm()does. - Backdrop dismissal only applies when the pointer interaction starts on the backdrop; selecting text or dragging from inside the panel cannot close the dialog accidentally.
- Page scroll is blocked via the CDK block scroll strategy while any dialog is open.
- A toast shown while a dialog is open appears above it, in the browser top layer, so its message is not hidden behind the backdrop.
- Without a
.kui-dialog-titlethe accessible name comes from thedialog.labelmessage (Dialog), and the confirm and cancel buttons ofkuiConfirm()from thedialog.confirmanddialog.cancelmessages. - The panel renders
.kui-dialog-closeitself, top-right of the header, whenclosableistrue(the default); the header reserves space for it automatically.dialogContext.closableis retained for informational use only.
Consumer-visible changes of @kikita-labs/ui 2.0 for Dialog.
- The imports are
KuiButtonand the rest of the renamed classes;ng update @kikita-labs/uirenames them.KuiDialogContext,KUI_DIALOG_CONTEXTandkuiDialog()keep their names. - Defaults come from
defaults.dialogand are read each time a dialog opens. Thefullscreensize is new. - The backdrop uses the
--kui-color-scrimrole, the layer comes from--kui-z-dialog(it was a literal 100) only where the browser lacks the Popover API, and the close button and icon sizes are tokens. - Button and close-mark icons are drawn by the shared structural icon renderer, and the accessible name and confirm labels come from the
dialogmessages.