Skip to content

nss_libs - NssConfirm

A Promise-based confirm and alert dialog. NUI

Getting Started

NssConfirm provides two static factory methods — confirm() for yes/no decisions and alert() for acknowledgment dialogs. Both return Promises.

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

NssConfirm.confirm('Delete this item?', 'Delete', 'Cancel', true)
    .then(() => { /* confirmed */ })
    .catch(() => { /* cancelled */ });

Static Methods

NssConfirm.confirm(message, yes_label, no_label, danger?)

Shows a confirm dialog with two buttons. Returns a Promise that resolves on confirm and rejects on cancel.

ParamTypeDefaultDescription
messagestringThe message to display. Supports HTML
yes_labelstringLabel for the confirm button
no_labelstringLabel for the cancel button
dangerbooleanfalseIf true, applies a danger/warning style

Returns Promise<void> — resolves on confirm, rejects on cancel.

js
NssConfirm.confirm('Are you sure?', 'Yes', 'No')
    .then(() => {
        nss_client.post('confirmed');
    })
    .catch(() => {
        // User cancelled — do nothing
    });

NssConfirm.alert(message, yes_label, danger?)

Shows an alert dialog with a single button.

ParamTypeDefaultDescription
messagestringThe message to display. Supports HTML
yes_labelstringLabel for the OK button
dangerbooleanfalseIf true, applies a danger/warning style

Returns Promise<void> — resolves when the user clicks the button.

js
NssConfirm.alert('Action completed successfully.', 'OK').then(() => {
    // User acknowledged
});
js
NssConfirm.alert('Invalid input!', 'OK', true).then(() => {
    input_el.focus();
});

Instance Methods

For advanced usage, you can create an instance directly.

.setMessage(message)

ParamTypeDefaultDescription
messagestringThe message HTML

Returns undefined.

js
const confirm = new NssConfirm();
confirm.setMessage('Custom message');

.setDanger()

Applies the danger style to the dialog.

Returns undefined.

js
confirm.setDanger();

.show()

Creates the dialog DOM and displays it with an animation.

Returns undefined.

js
confirm.show();

.hide()

Plays the out-animation and removes the dialog DOM.

Returns undefined.

js
confirm.hide();

Events / Callbacks

  • Confirm — the Promise resolves (or yes_callback fires).
  • Cancel — the Promise rejects (or no_callback fires).
  • Backdrop click — triggers the cancel/no action.

CSS

Classes

ClassDescription
.nss-confirm-modalFull-screen backdrop overlay (z-index 2000).
.nss-confirm-modal--outFade-out animation state.
.nss-confirm-dialogCentered dialog box (z-index 2001).
.nss-confirm-dialog--outSlide-out animation state.
.nss-confirm__contentMessage content area.
.nss-confirm__buttonsButton row container.

Custom Properties

PropertyDefaultDescription
--nss-confirm-anim-dur500msAnimation duration (fade + slide). Defined on :root.

Animations

KeyframeDescription
nss-confirm-anim__fade-in / fade-outBackdrop opacity animation.
nss-confirm-anim__slide-in-top / slide-out-bottomDialog slide animation.

Dependencies

  • NssUiComponent — base class (initializes NssResponsive).

Things to Know

  • The static methods confirm() and alert() are the recommended way to use this component. Direct instantiation is only needed for advanced use cases.
  • Clicking the backdrop always triggers the cancel action (rejects the Promise).
  • The danger flag changes the visual style but not the behavior.
  • The animation duration is read from the CSS variable --nss-confirm-anim-dur — override it to change the speed.

NIGHTSHIFT STUDIO Documentation