Skip to content

NssTip

A toast/notification component with configurable position and auto-hide duration. NUI

Getting Started

NssTip displays a temporary message at a configurable screen position. It fades in, stays for a set duration, and fades out automatically.

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

const tip = new NssTip('Item added to inventory');
tip.setBottomCenter().setDuration(3000).show();

Constructor

new NssTip(message)

Creates a new tip with the given message.

ParamTypeDefaultDescription
messagestringThe message to display. Supports HTML
js
const tip = new NssTip('Settings saved');
const tip = new NssTip('<strong>Error:</strong> Invalid input');

Methods

.show()

Displays the tip and automatically hides it after the configured duration.

Returns Promise<void> — resolves when the tip has fully faded out and been removed.

js
tip.show().then(() => {
    console.log('Tip is gone');
});

.hide(force_now?)

Hides the tip with a fade-out animation, or removes it immediately.

ParamTypeDefaultDescription
force_nowbooleanfalseIf true, removes the tip immediately without animation

Returns undefined

js
tip.hide();           // Fade out
js
tip.hide(true);       // Remove immediately

.destroyNow()

Shorthand for hide(true) — removes the tip immediately.

Returns undefined

js
tip.destroyNow();

.setDuration(ms)

Sets the auto-hide duration.

ParamTypeDefaultDescription
msnumber4000Duration in milliseconds before the tip auto-hides

Returns NssTip — chainable.

js
tip.setDuration(5000); // Show for 5 seconds

Position Methods

Set the screen position of the tip. Default is bottom-center. All position methods return NssTip for chaining.

MethodPosition
setTopLeft()Top-left corner
setTopCenter()Top-center
setTopRight()Top-right corner
setCenterLeft()Center-left
setCenterCenter()Center of screen
setCenterRight()Center-right
setBottomLeft()Bottom-left corner
setBottomCenter()Bottom-center (default)
setBottomRight()Bottom-right corner
js
new NssTip('Something went wrong')
    .setCenterCenter()
    .setDuration(5000)
    .show();
js
new NssTip('Saved!')
    .setTopRight()
    .show();

Events / Callbacks

None. Use the Promise returned by show() to react to the tip disappearing.

CSS

Classes

ClassDescription
.nss-tipBase tip element
.nss-tip--outFade-out animation state
.nss-tip--tlTop-left position
.nss-tip--tcTop-center position
.nss-tip--trTop-right position
.nss-tip--clCenter-left position
.nss-tip--ccCenter-center position
.nss-tip--crCenter-right position
.nss-tip--blBottom-left position
.nss-tip--bcBottom-center position (default)
.nss-tip--brBottom-right position

Custom Properties

PropertyDefaultDescription
--nss-tip-anim-duration500msFade in/out animation duration. Defined on :root
--marginvar(--25rpx)Margin from screen edge

Animations

KeyframeDescription
nss-tip-anim__fade-inOpacity 0 → 1
nss-tip-anim__fade-outOpacity 1 → 0

Dependencies

  • NssUiComponent — base class (initializes NssResponsive).

Things to Know

TIP

Each NssTip instance is a one-shot display — after it fades out, the DOM element is removed. Create a new instance for each notification.

  • The total visible time is duration + 500ms (animation in/out time).
  • Multiple tips can be shown simultaneously at different positions — they don't interfere with each other.
  • The message supports HTML, so you can include formatting like <strong>, <em>, or custom elements.

NIGHTSHIFT STUDIO Documentation