Skip to main content
cngx-src documentation

CngxLoadingOverlay

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/ui/feedback/loading/loading-overlay.ts

Import#

import { CngxLoadingOverlay } from '@cngx/ui/feedback'

Description#

Loading overlay - content container that blocks interaction while loading.

Projects content inside a wrapper that receives inert during loading. Renders a centered spinner over a semi-transparent backdrop. Manages focus save/restore across the inert lifecycle.

Uses display: grid with a shared grid cell - backdrop and content overlap naturally without position: absolute or display: contents.

With async state

<cngx-loading-overlay [state]="tableData">
  <table>...</table>
</cngx-loading-overlay>

Manual boolean

<cngx-loading-overlay [loading]="isSaving()">
  <form>...</form>
</cngx-loading-overlay>

First load only (refresh uses the container's built-in bar)

<cngx-loading-overlay [state]="query" [firstLoadOnly]="true">
  <cngx-async-container [state]="query">...</cngx-async-container>
</cngx-loading-overlay>

https://cngxjs.github.io/cngx/examples/#/ui/feedback/loading-overlay/overlay-with-form

Metadata#

Relationships

Index#

Inputs#

delay#number
input()

Delay in ms before showing the overlay. Falls back to global config, then 200ms.

default this.config?.loadingDelay ?? 200
firstLoadOnly#boolean
input()

When true, the overlay only activates during the first load (isFirstLoad()), not during refreshes. Use the async container's built-in refresh bar for subsequent loads to avoid content jumps under the backdrop.

default false
label#string
input()

Screen reader label for the spinner.

default 'Loading'
loading#boolean
input()

Direct boolean control - alternative to [state].

default false
minDuration#number
input()

Minimum display time in ms once visible. Falls back to global config, then 500ms.

default this.config?.loadingMinDuration ?? 500

Bind an async state - shows overlay when isBusy().

Default visuals for CngxLoadingOverlay. The host carries .cngx-loading-overlay and lays out its __content and __backdrop children as a single-cell grid so the backdrop stacks over the content; the backdrop centers a __spinner-wrapper with its own focus-visible ring.

Slots

  • .cngx-loading-overlay__content - main content (grid area 1/1)
  • .cngx-loading-overlay__backdrop - scrim with centered spinner, z-ordered at --cngx-loading-overlay-z-index (default 10); opacity fade respects prefers-reduced-motion
  • .cngx-loading-overlay__spinner-wrapper - focus target for the spinner with a circular focus ring on :focus-visible

Dark mode

Three hooks invert the translucent-white backdrop to translucent- dark so the spinner stays visible over a dark page; the overlay is a scrim, not a surface, so it does not delegate to --cngx-color-surface:

  • prefers-color-scheme: dark
  • [data-color-scheme="dark"]
  • .dark class

Index#

Layout

--cngx-loading-overlay-z-index#<number>
Default value 10

Stacking-context order of the overlay above its content.

Surface

--cngx-loading-overlay-backdrop-bg#<color>
Default value oklch(1 0 0 / 0.5)

Backdrop background - translucent white by default; override for dark themes.

--cngx-loading-overlay-backdrop-opacity#<number>
Default value 1

Backdrop opacity multiplier.

Motion

--cngx-overlay-transition-duration#<time>
Default value 150ms

Opacity-fade transition duration for the overlay show/hide.

--cngx-overlay-transition-easing#*
Default value ease

Easing curve of the overlay show/hide transition.