Message
Display global messages as feedback in response to user operations.
Examples
Basic
A basic example of an information message.
Status
System status can be communicated using success
, warning
, or error
messages.
Custom Duration
Customize the message display duration by using the duration
option. The default is 3000
(3 seconds).
The message will never dismiss if the duration
is set to 0
.
Loading Indicator
Display a global loading indicator, which can be dismissed asynchronously. The resolved value of the message call promise is a destroy
function.
Promise Interface
message
provides a promise interface for performing actions after it closes. This example will display a new message when the old message closes.
Updating a Message
A message can be updated by using a unique key
.
API
This component provides the following static methods:
message.success
message.error
message.info
message.warning
message.warn // alias of warning
message.loading
Each returns a promise that resolves when the message closes.
If no additional configuration is needed, a string can be passed as the argument and will render as the content of the message. Otherwise a config object should be passed.
Config Attributes
Property | Description | Type | Default |
---|---|---|---|
content | Content of the message | String | - |
duration | Time (milliseconds) before auto-dismiss, don't dismiss if set to 0 | Number | 3000 |
icon | Custom icon | SvelteComponent | - |
key | A unique identifier for the message | String|Number | - |
Global Configuration
A message.config
method is also provided.
message.config({
top: 100,
duration: 2000,
maxCount: 3,
rtl: true,
});
Global Config Options
Property | Description | Type | Default |
---|---|---|---|
duration | Time before auto-dismiss, in milliseconds | Number | 3000 |
maxCount | Max messages to show at one time, drop oldest if limit is exceeded | Number | |
top | Distance from top (pixels) | Number | |
top | Whether to enable RTL (Right to left) mode | Boolean | false |