Skip to main content

upp-dialog

A centered modal shell with a backdrop mask and content projection. It is an embedded alternative to Ionic ModalController: the consumer controls visibility (*ngIf or similar) and projects title, form, and actions inside the panel.

When to Use

Use upp-dialog for short confirmations or compact forms that need a modal overlay without registering a separate Ionic modal. Typical consumers wrap business content (for example account settlement) and listen to OnClose to hide the shell.

The host applies desktop or mobile classes from viewService. On desktop the panel is a centered card; on mobile it fills the viewport. After mount the host reparents to document.body so a fixed overlay always covers the full viewport.

Demo

Source Code

<h2>upp-dialog</h2>
<p class="demo-description">
Centered modal shell with <code>upp-dialog-header</code> / <code>upp-dialog-content</code> /
<code>upp-dialog-footer</code> slots. The host reparents to <code>document.body</code> so the overlay covers the full viewport.
</p>

<div class="demo-controls">
<ion-button size="small" (click)="OnOpen()">Open dialog</ion-button>
<ion-button size="small" fill="outline" (click)="OnToggleBackdrop()">
backdropDismiss: {{ backdropDismiss }}
</ion-button>
</div>

<upp-dialog *ngIf="open" [backdropDismiss]="backdropDismiss" (OnClose)="OnClose()">
<upp-dialog-header class="demo-dialog-header">
<h3>Confirm action</h3>
<ion-button fill="clear" size="small" (click)="OnClose()">
<ion-icon slot="icon-only" name="close-outline"></ion-icon>
</ion-button>
</upp-dialog-header>

<upp-dialog-content class="demo-dialog-body">
<p>Click the backdrop, press Escape, or use Close / Confirm below.</p>
<p *ngFor="let line of scrollLines">{{ line }}</p>
</upp-dialog-content>

<upp-dialog-footer class="demo-dialog-footer">
<ion-button expand="block" fill="outline" (click)="OnClose()">Close</ion-button>
<ion-button expand="block" color="warning" (click)="OnClose()">Confirm</ion-button>
</upp-dialog-footer>
</upp-dialog>

API Reference

upp-dialog

Input / OutputTypeDefaultDescription
backdropDismissbooleantrueWhen true, backdrop click, Enter, and Space emit OnClose.
OnCloseEventEmitter<void>Emitted when the user dismisses the dialog (backdrop when allowed, or Escape).

Host classes: mobile when viewService.Mobile is true; desktop when viewService.Desktop is true.

Content projection: markup inside <upp-dialog>…</upp-dialog> is rendered in the centered panel. For fixed header/footer with a scrolling body, project into the structural slots:

SlotRole
upp-dialog-headerFixed top region (flex: 0 0 auto)
upp-dialog-contentScrollable body (upp-scrollable; @Input() scrollbar, default 'y')
upp-dialog-footerFixed bottom region (flex: 0 0 auto)

Visual chrome (colors, typography, padding) stays in the consumer’s classes on those slots. After mount the host reparents to document.body, so set CSS variables with an inline style on <upp-dialog> (not a descendant selector in the caller SCSS).

CSS variables (on :host):

VariableDefaultDescription
--upp-dialog-panel-width420pxPreferred width of the desktop panel (min(var, 100%) of the overlay)
--upp-dialog-panel-inset24pxOuter padding around the desktop panel
--upp-dialog-panel-inset-blockvar(--upp-dialog-panel-inset)Top/bottom overlay padding (desktop)
--upp-dialog-panel-inset-inlinevar(--upp-dialog-panel-inset)Left/right overlay padding (desktop)
--upp-dialog-panel-radius10pxBorder radius on desktop
--upp-dialog-z-index12000Stacking order of the overlay