Skip to content

NssLoadingIndicator

An animated loading spinner overlay. NUI

Getting Started

NssLoadingIndicator displays a fullscreen or element-scoped loading animation. It fades in/out smoothly and returns Promises for animation completion.

js
import {NssLoadingIndicator} from "nui://nss_libs/ui/NssLoadingIndicator/NssLoadingIndicator.js";

const loading = new NssLoadingIndicator(document.getElementById('content'));
loading.show();

// Later, when loading is complete:
loading.hide();

Constructor

new NssLoadingIndicator(target_el?)

Creates a new loading indicator instance.

ParamTypeDefaultDescription
target_elHTMLElementdocument.bodyThe element the indicator will overlay
js
const loading = new NssLoadingIndicator();
js
const loading = new NssLoadingIndicator(dialog_el);

Methods

.show()

Displays the loading indicator with a fade-in animation.

Returns Promise<void> — resolves when the fade-in animation completes.

js
const loading = new NssLoadingIndicator(container_el);
loading.show().then(() => {
    console.log('Indicator is fully visible');
});

.hide()

Hides the loading indicator with a fade-out animation.

Returns Promise<void> — resolves when the fade-out animation completes.

js
loading.hide().then(() => {
    console.log('Indicator is hidden');
});

.destroy()

Hides the indicator and removes its DOM element completely.

Returns Promise<void> — resolves after the element is removed.

js
loading.destroy().then(() => {
    console.log('Indicator destroyed and removed from DOM');
});

Events / Callbacks

None. Use the returned Promises to react to animation completion.

CSS

Classes

ClassDescription
.nss-loading-indicatorRoot overlay with radial gradient background
.nss-loading-indicator--hiddenHidden state (display: none)
.nss-loading-indicator--showFade-in animation trigger (0.3s)
.nss-loading-indicator--hideFade-out animation trigger (0.3s)
.quest-loading-indicator__loaderInner loader container
.quest-loading-indicator__loader-imgAnimated spinner image (inverted colors)

Animations

KeyframeDescription
nss-loading-indicator-anim__fade-inOpacity 0 → 1
nss-loading-indicator-anim__fade-outOpacity 1 → 0

Dependencies

  • NssUiComponent — base class (initializes NssResponsive).
  • Consumes --1rpx and --10rpx from NssResponsive.css.

Things to Know

TIP

The DOM is created lazily on the first show() call.

  • If you need overlapping loading indicators on different elements, create a separate instance for each — do not reuse a single instance.
  • NssClient uses NssLoadingIndicator internally when a loading_indicator_target_el is passed to post().
  • hide() only visually hides the element. Use destroy() to also remove it from the DOM.

NIGHTSHIFT STUDIO Documentation