Skip to content

Message

Imperative global message notifications with support for types, custom duration, and manual dismissal.

Basic usage

Four types

SuccessErrorWarningInfo

Custom duration

Custom duration

2s5sNo auto-close (0)

Manual close

Manual close

Show messageClose manually

Clear all

Clear all

Fire threeClear all

Grouped messages

Messages with the same group merge into a single one; repeated triggers increment the count (×n). Different groups are independent.

Grouped messages

Save (click repeatedly)Sync (another group)

Updating messages

Tag a message with key, then update its content/type via message.update(key, options) and close it via message.destroy(key).

Updating messages

Start uploadMark as successClose this message

API

Methods

MethodDescription
message.info(content, duration?) / message.info(content, options?)Info message, returns { close }
message.success(content, duration?) / message.success(content, options?)Success message, returns { close }
message.warning(content, duration?) / message.warning(content, options?)Warning message, returns { close }
message.error(content, duration?) / message.error(content, options?)Error message, returns { close }
message.update(key, { content, type?, duration? })Update content/type of an existing message; creates a new one if the key does not exist
message.destroy(key)Close the message identified by key
destroyAllMessage()Clear all messages

Attributes

AttributeDescriptionTypeDefault
countMerge count (shows ×n after content when > 1)string0
durationAuto-close duration (ms), 0 to keep openstring3000
groupGroup id: messages in the same group merge into one
keyUnique id: used by message.update / message.destroy
typeMessage type: info/success/warning/errorstringinfo

Events

EventDescription
oas-closeEmitted when the message closes (auto-close / close button / destroy), detail: { key? }
  • options: { duration?, group?, key?, onClose? }. group merges messages into one and increments the count; key is used by update / destroy; onClose fires when the message closes.
  • duration defaults to 3000ms; pass 0 to keep the message open.
  • When a message closes (auto-close / close button / destroy), oas-close is emitted with detail: { key? }.
  • Stacked and centered at the top; error uses role="alert", others use role="status".

Released under the MIT OR Apache-2.0 License.