Skip to content

nss_libs - UI Components

This directory contains the NUI components for nss_libs. NUI

Simple: ES6 Module Import

Import any component directly via ES6 module import:

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

Load Components via NssUiApi

Load multiple components at once using NssUiApi. This ensures all components and their styles are ready before use.

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

const nss_ui_api = new NssUiApi('your_resource_name'); 

const component_names = [
    NssUiApi.NssResponsive,
    NssUiApi.NssSvgReplacer,
    NssUiApi.NssTextBox
];

nss_ui_api.load(component_names).then((components) => { 
    new components.NssResponsive();
    new components.NssSvgReplacer();

    // Components are ready to use
});

Local Development (without RedM)

For developers who want to test NUI locally in Chrome without a running RedM server:

  1. Create a wrapper file nss_ui_api.js in your HTML script root:
js
const is_cfx_browser = navigator.userAgent.indexOf("CitizenFX") > -1;

let imp_obj;

if (is_cfx_browser) {
    imp_obj = await import("nui://nss_libs/ui/NssUiApi.js");
} else {
    // Adapt relative path to your project structure
    imp_obj = await import("../../../../../[nss]/nss_libs/ui/NssUiApi.js");
}

const NssUiApi = imp_obj.NssUiApi;

export {NssUiApi};
js
import {NssUiApi} from "./nss_ui_api.js";

const nss_ui_api = new NssUiApi('your_resource_name');

nss_ui_api.load([NssUiApi.NssResponsive]).then((components) => {
    new components.NssResponsive();
    // Ready
});

Available Components

ComponentDescription
NssAudioAudio player for sound effects with built-in SFX library.
NssButtonsStyled buttons with colors, sizes, glow effects, and click callbacks.
NssClientNUI ↔ Lua client communication bridge via XHR.
NssConfirmPromise-based confirm and alert dialogs.
NssHelperStatic utility functions (debounce, animation, cloning).
NssLoadingIndicatorAnimated loading spinner overlay.
NssModalAnimated full-screen modal with customizable content.
NssPadLockInteractive combination lock PIN entry UI.
NssResponsiveResponsive scaling system based on screen width.
NssSimpleTextEditorSection-based rich text editor with validation.
NssSvgReplacerReplaces <img> SVGs with inline SVG for CSS styling.
NssTextBoxStyled text display with decorative frame.
NssTipToast/notification with configurable position and duration.

NIGHTSHIFT STUDIO Documentation