NSS Docs
DiscordStoreHomepage
nss_libs
nss_libs
  • README
  • Changelog
  • UI components
    • NssUiApi basics
    • NssAudio
    • NssButton
    • NssClient
    • NssConfirm
    • NssHelper
    • NssLoadingIndicator
    • NssModal
    • NssPadLock
    • NssResponsive
    • NssSimpleTextEditor
    • NssSvgReplacer
    • NssTextBox
    • NssTip
  • Client/server modules
    • AttachProp
    • Blip
    • Character
      • Client Character
      • Server Character
    • Chunk
    • ClientEvent
    • ConfigValidator
    • Database
    • DatabaseUpdater
    • DependencyAutoRestart
    • Discord
    • EntityInRange
    • Helper
      • Client Helper
      • Server Helper
      • Shared Helper
    • Inventory
    • Keyboard
    • Notify
    • Npc
    • ParticleFxPlayer
    • PointInRange
    • Prompts
    • ServerEvent
    • VersionCheck
Powered by GitBook
On this page
  • How to use
  • ES6 module import
  • Create instance

Was this helpful?

  1. UI components

NssModal

PreviousNssLoadingIndicatorNextNssPadLock

Last updated 1 year ago

Was this helpful?

Provides an animated modal with customizable content. The modal considers if the user currently typing in an editable element (like input or textarea) and prevents the modal from closing if a close key was pressed during typing.

How to use

ES6 module import

For NssUiApi usage, please see the of the nss_libs/ui folder.

Alternative example of direct ES6 module import:

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

Create instance

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

const content_el = document.createElement("div");
content_el.innerHTML = "Hello World!";

/**
 * @type {NssModal}
 */
const nss_modal = new NssModal();

nss_modal
    .closeOnModal()
    .closeOnEscape()
    .closeOnBackspace()
    .setContent(content_el)
    .onClose(() => {
        // Do your stuff here...
    })
    .show();

// Example: Close modal after 3 seconds automatically
window.setTimeout(() => {
    nss_modal.hide();
}, 3000);
README.md