vUX / MessageBox / v4.1.0

Say it once.
Then get out of the way.

Notifications that drop in from the top, stack without jumping, wait while you read them, and leave on their own.

box.success("Changes saved", { title: "Done" })

01Playground

Every control below sets a config property on one live instance, so each message you post uses what is set at that moment. Messages already on screen keep the settings they arrived with.

Where and how
Timing and size
Behaviour
Message
0 open
Equivalent code

                
onShow / onClose

02Five ways in

drop, slideLeft and slideRight are driven by the core slide utility, $$.sm(el).slide. Each leaves the way it came. The space a message takes in its lane opens and closes with the same utility, which is why the others never jump.

drop

Falls from above

Starts just above the window and drops to its place in the lane. On close it rises back out. This is the default.

slideLeft

From the right edge

Travels leftwards to wherever its alignment puts it. A centred one stops in the middle. It leaves back out to the right.

slideRight

From the left edge

The mirror image of slideLeft: comes in from the left and leaves back out through it.

fade

Quiet

A short fade and settle in place. Every other effect falls back to this one when the visitor asks for reduced motion.

none

Instant

No animation at all. A speed of 0 means the same thing with any effect.

03Messages you hold on to

show() returns a handle. Use it to close a message when you decide, rather than when the timer does. Content can also be an element, so a message can carry your own controls.

duration: 0 + handle.close()

A sticky "Saving…" message that stays up until the work it reports on finishes, then gives way to the result.

element content

The message body is a node of the page's own, with an Undo button wired by the page. Pressing it closes the message through the handle.

3 files

04Bad input fails immediately

Every config property and every per-call option is checked when it is set, by the same rule, so a typo throws to your code instead of producing a message that silently ignores it.

No error yet. Press one of the buttons above.