Skip to content
OGE logoOGE

Modal

oge-modal is the centered dialog primitive: backdrop, focus trap, body scroll lock, Escape/backdrop closing and focus restore. Content renders lazily behind the opened model and joins the shared overlay Escape stack, so popups opened inside the modal close before the modal itself. Declare it near the component root — transformed ancestors break position: fixed.

oge-modal [(opened)] closeGuard *ogeModalFooter

Basics

Open declaratively via the two-way opened model or imperatively with open()/close()/toggle(). The footer slot's let close function closes the modal; Escape, backdrop clicks and the ✕ button work out of the box and focus returns to the opener.

[(opened)] title *ogeModalFooter

Form content & stacked popups

Any content projects into the body — including dropdown editors. Their popups render above the modal, and the shared Escape stack closes the topmost surface first: one Escape for the open select popup, a second for the modal.

width oge-select-box Escape stack

Full screen, placement & sizing

showMaximizeButton puts a maximize/restore toggle in the title bar, driving the two-way fullScreen model (size inputs are ignored while full screen). placement="top" pins the dialog near the top edge — command-palette style — and [shading]="false" keeps the backdrop transparent while staying fully modal. Sizing accepts width/height plus min/max variants, as numbers (px) or CSS strings.

[(fullScreen)] placement shading min/max size

Window mode & modal service

dragEnabled makes the title bar a drag handle (viewport-clamped unless dragOutsideBoundary), resizeEnabled adds a corner handle with resizeStarted/resized events, and restorePosition resets both on reopen. For imperative flows — or transformed ancestors — OgeModalService.open(component, config) renders a body-appended modal; the content injects OGE_MODAL_DATA and closes itself via OgeModalRef, whose closed promise carries the typed result. inertBackground additionally marks the page behind the modal inert.

dragEnabled resizeEnabled OgeModalService inert
service result: —

Async close guard

closeGuard runs before every close — Escape, backdrop, ✕ and close() alike — and may return a Promise<boolean>: the modal stays open until it resolves, single-flight guarded. No other library covers the async unsaved-changes veto without hand-rolled plumbing. A direct opened model write bypasses the guard (the app already decided).

closeGuard closePending async veto

Busy state

While busy is true the modal shows a spinner veil, sets aria-busy and blocks user-initiated closes — programmatic close() still works, so finish your async work and close. Pairs naturally with the button family's async action.

busy aria-busy spinner veil

Loading and blocked closes

loading veils the body while content arrives but, unlike busy, leaves Escape, the backdrop and ✕ working. When a close does not go through, closeBlocked says why — busy, a cancelled closing, or closeGuard — so the page can explain it. autoFocus: false focuses the panel and no control, so no on-screen keyboard pops up for the first field.

loading closeBlocked autoFocus: false

Typed result

close(result) — from code or the footer slot — carries a typed value into closed, alongside the close reason. Declarative confirm/prompt flows no longer need side-channel component state.

close(result) OgeModalClosedEvent reason
outcome: —

Dialog helpers

OgeModalService.confirm(), alert() and prompt() return promises — boolean, void and string | null. Confirm and alert are APG alert dialogs (role="alertdialog", described by the message); severity picks a built-in icon (icon: false hides it, a TemplateRef replaces it) and danger makes the primary button destructive and moves the initial focus to Cancel. Enter runs the primary action — in the prompt field too, unless it is invalid — and Escape cancels (an alert counts it as OK). Prompt validation (required, sync or async validate) renders the error beside the field with aria-invalid and aria-describedby. Button labels default to the localized dialogOk / dialogCancel messages.

confirm() alert() prompt() danger validate
result: —

Irreversible actions

For an action that cannot be undone, confirm() takes gates: details lists what will go (a text, or bullets), typeToConfirm asks for an exact text — the project name here — and acknowledgeLabel a ticked box; canAccept(state) adds a rule of your own. The primary button stays disabled until every gate passes, the field gets the initial focus, and its label comes from the localized dialogTypeToConfirm message.

details typeToConfirm acknowledgeLabel canAccept
result: —

Placements

placement pins the panel to the centre, an edge — top, bottom, start, end — or a corner (top-start … bottom-end). start and end are logical: they follow the reading direction, so a dir="rtl" page mirrors them without extra configuration. The service and the dialog helpers take the same option.

placement start / end corners RTL

Part styling

Bring a design system along without forking styles. panelClass, backdropClass and bodyClass add classes next to the modal's own (string, array or { name: boolean }), bodyStyle sets inline body styles, and panelAttributes puts data-* / aria-* attributes on the panel — filtered, so event handlers, style, class and script URLs are never written. Component tokens (--oge-modal-radius, --oge-modal-bg, --oge-modal-body-padding…) restyle only modals inside the element that sets them; the popover, the popups and the buttons have the same pair of options and their own tokens.

panelClass backdropClass bodyClass panelAttributes component tokens

Notes

  • autoFocus picks the initial focus target: 'first-tabbable' (default), 'panel', or any CSS selector; an [autofocus] element always wins.
  • The panel (.oge-modal) is a child of the backdrop layer (.oge-modal-layer). A declared modal stays where it is declared, so it inherits the theme tokens of its container; under a transform, filter, backdrop-filter or containment ancestor it moves to the browser's top layer (popover="manual") without leaving its DOM position. Popups opened inside it (select box, date box, menus) do the same, so none of them needs an appendTo option, and a click inside a nested popup never counts as an outside click.
  • busy blocks Escape, backdrop clicks and the ✕ before closing fires; close() still runs the pipeline, and writing opened to false closes at once with closed reason 'api'.
  • Headerless modals (showCloseButton=false, no title) should set ariaLabel; [padding]="false" makes the body flush for grids and custom layouts.
  • The ✕ button's aria label localizes via provideOgeOverlayConfig({ messages: { modalClose: '…' } }) or the per-instance messages input.
  • Body scroll locks while open (scrollbar-width compensated, ref-counted across stacked modals) — disable with [scrollLock]="false".