Skip to main content
cngx-src documentation

CngxLoadingIndicator

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

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

Import#

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

Description#

Loading indicator atom - purely visual, blocks no interaction.

Two variants:

  • spinner - rotating circle, inline or centered
  • bar - thin line at the top of the container (YouTube-style)

Timing:

  • delay (default 200ms): operations faster than this never show the indicator
  • minDuration (default 500ms): once visible, stays for at least this long

For content-blocking overlays, use cngx-loading-overlay instead.

With async state

<cngx-loading-indicator [state]="residents" variant="bar" />

Manual boolean

<cngx-loading-indicator [loading]="isLoading()" label="Fetching data" />

https://cngxjs.github.io/cngx/examples/#/ui/feedback/loading-indicator/bar-variant https://cngxjs.github.io/cngx/examples/#/ui/feedback/loading-indicator/spinner-variant

Metadata#

Host#

Relationships

Index#

Inputs#

delay#number
input()

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

default this.config?.loadingDelay ?? 200
label#string
input()

Screen reader label.

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 indicator when isBusy().

input()

Visual variant.

default 'spinner'

HostBindings#

BindingExpression
[class.cngx-loading-indicator--visible]visible()
[class.cngx-loading-indicator--spinner]variant() === "spinner"
[class.cngx-loading-indicator--bar]variant() === "bar"
[attr.role]"status"
[attr.aria-label]visible() ? label() : null
[attr.aria-busy]isActive() || null

Default visuals for CngxLoadingIndicator. The host carries .cngx-loading-indicator and renders either __spinner (with nested __spinner-track + __spinner-arc SVG paths) or __bar (with nested __bar-fill). Keyframes (cngx-spin, cngx-bar-indeterminate, cngx-pulse) stay top-level outside @layer because they are already namespaced.

Variants

  • default - circular SVG spinner, cngx-spin 360deg rotation
  • --bar - block-level indeterminate progress bar with a 40% fill sweep via cngx-bar-indeterminate

Under prefers-reduced-motion both variants swap to a slow opacity pulse (cngx-pulse); the bar variant additionally pins width: 100% so the static fill reads as a track-fill rather than a stuck partial sweep.

Slots

  • .cngx-loading-indicator__spinner-track - background ring stroke (--cngx-loading-indicator-track)
  • .cngx-loading-indicator__spinner-arc - active arc stroke (--cngx-loading-indicator-color)
  • .cngx-loading-indicator__bar - bar track (same track token)
  • .cngx-loading-indicator__bar-fill - bar fill (same active token)

Index#

Layout

--cngx-loading-bar-height#<length>
Default value 3px

Track height of the bar variant.

--cngx-loading-bar-radius#<length>
Default value 0

Corner radius of the bar variant.

--cngx-loading-indicator-size#<length>
Default value 24px

Diameter of the spinner ring.

Surface

--cngx-loading-indicator-track#<color>
Default value oklch(0 0 0 / 0.1)

Track color of the spinner ring and the indeterminate bar.

--cngx-loading-indicator-color#*
Default value currentColor

Stroke / fill color of the active indicator.

Motion

--cngx-spin-duration#<time>
Default value 0.8s

Spinner rotation duration.

--cngx-spin-easing#*
Default value linear

Spinner easing curve.

--cngx-bar-duration#<time>
Default value 1.5s

Bar sweep duration.

--cngx-bar-easing#*
Default value ease-in-out

Bar sweep easing curve.

--cngx-pulse-duration#<time>
Default value 2s

Opacity-pulse duration used as the reduced-motion fallback.

--cngx-pulse-easing#*
Default value ease-in-out

Opacity-pulse easing curve.