# KptDialog (kpt-dialog) A modal window on the native `` (focus trap, Esc, a backdrop out of the box). Import: `import { KptDialog } from '@konce-pt/angular';` ## Selector `kpt-dialog` ## Inputs - `open`: model - two-way `[(open)]` - `header`: string; `dismissible`: boolean (Esc/x closes it; default true) - `size`: 'sm' | 'md' | 'lg' | 'full' (default 'md') - 24rem / 32rem / 48rem, always capped at the viewport (`min(var(--_width), calc(100vw - 2rem))`). Reach for `lg` when the content cannot sensibly be narrowed: code, a table, two columns side by side. `full` covers the whole screen (`100vw` x `100dvh`, no border, radius or margin, safe-area padding) and the body grows to the full height - for a camera preview, an editor, or a window that should be its own screen on a phone: `[size]="phone() ? 'full' : 'md'"`. - `ariaLabel`: string - the name of a dialog with no `header` (with one, the header names it) - `ariaDescribedby`: string | null - the `id` of the element that describes the dialog - `alert`: boolean - `role="alertdialog"`, for a window that interrupts and demands an answer ## Slots - the default content -> the body; an element with the `kptDialogFooter` attribute -> the footer ## Example This cannot be undone.
Cancel Delete
## Tokens `--kpt-color-surface-raised`, `--kpt-color-overlay-scrim` (::backdrop), `--kpt-elevation-4`. Note: the global reset zeroes the margin - the component restores `margin:auto` (centering). ## CDK Overlay controls inside the dialog `kpt-dialog` stands on the native `` and opens through `showModal()`, which lifts it into the browser's **top layer** - and that sits above the entire document tree, where no `z-index` can reach it. The CDK Overlay container hangs off `` by default, so the panels of `kpt-select`, `kpt-datepicker`, `kpt-autocomplete` and `kpt-menu` would open inside the dialog INVISIBLE, hidden behind its background. That is why, while it is open, `kpt-dialog` moves the overlay container inside the `` and puts it back on close (including when the component is destroyed with the dialog open). Nothing needs configuring - overlay controls behave inside the dialog exactly as they do outside it. ## Layout and scrolling An open dialog is a flex column: the header (`.kpt-dialog__header`) and the footer (`[kptDialogFooter]`) stay put, and only `.kpt-dialog__body` scrolls. The scrollbar therefore runs alongside the content, not alongside the whole dialog. The content gets `flex: 0 1 auto` (the default) + `min-height: 0`, deliberately **not** `flex: 1` as in `kpt-drawer`. A drawer fills the height of the screen, a dialog is meant to shrink to its content: a short one (`kpt-confirm` - two sentences and two buttons) stays short, a long one stops at `max-height: calc(100vh - 4rem)` and scrolls the content alone. The `display: flex` declaration is scoped with `&[open]` and has to stay that way. The `dialog:not([open]) { display: none }` rule comes from the browser stylesheet, and any author declaration beats it - including one inside `@layer`. An unscoped `display: flex` would leave every closed dialog visible on the page. `.kpt-dialog` does not get `overflow: hidden` - while it is open the CDK Overlay container is moved inside the `` (see the section above), so clipping the dialog would cut off the panels of `kpt-select` or `kpt-datepicker`. It is not needed for scrolling either: once it is a flex column, nothing sticks out of the dialog. ## The footer wraps `[kptDialogFooter]` is a flex row with `flex-wrap: wrap`, and the wrapping is not cosmetic. A dialog that does not fit its buttons does not let them stick out - they get **clipped**, because the browser gives `` its own scrolling box. Four buttons in an `sm` dialog are enough for the first one to become unreadable with no way to reach it. Wrapping turns that into a second row. A pinned action bar inside the content (say "Cancel / Save" in `kpt-map-create-dialog`) is done with `position: sticky` - the scrolling container is `.kpt-dialog__body`. The negative side margins have to match its padding (`--kpt-space-6`), and the `bottom` offset has to mirror the negative bottom margin (`bottom: calc(var(--kpt-space-6) * -1)`) - stickiness is computed for the margin box, so with `bottom: 0` a sliver of content would slide underneath the bar. ## Accessibility `showModal()` gives the focus trap, Escape and the inert page; focus returns to the opener on close. With `header` the dialog is named by its `

` (`aria-labelledby`); without it pass `ariaLabel`. `alert` + `ariaDescribedby` make it an alert dialog whose message is read out on open - `kpt-confirm-container` uses exactly that. ## Scrolling and non-dismissible windows An open window locks page scrolling underneath (a shared counter with drawers and bottom sheets, so nested windows do not release each other). With `dismissible` off the window gets `closedby="none"`, and if a browser still closes it on a gesture (Chromium lets the second Escape in a row through `cancel`), it is reopened - only code can close it.