logo

Message

Display global messages as feedback in response to user operations.

When To Use

  • To provide feedback such as success, warning, error etc.
  • A message is displayed at top and center and will be dismissed automatically, as a non-interrupting light-weighted prompt.

Examples

Normal message for information.

expand code expand code

Customize message display duration from default 3s to 10s.

expand code expand code

Message provides a Task interface for onClose. The above example will display a new message when the old message is about to close.

expand code expand code

Display a loading indicator during asynchronous operations, which is automatically dismissed when the operation completes. The LoadingWhen extension method simplifies this process.

expand code expand code

Messages of success, error and warning types.

expand code expand code

Display a global loading indicator, which is dismissed by itself asynchronously.

expand code expand code

Update message content with unique key.

expand code expand code

Message API#

Property Description Type Default Value
Id ParameterID for the component's HTML String Uniquely Generated ID
Class ParameterSpecifies one or more class names for an DOM element. String --
Style ParameterSpecifies an inline style for a DOM element. String --
RefBack ParameterA ForwardRef instance. You can get a reference to the internal DOM by using AntDesign.ForwardRef.Current. ForwardRef --

IMessageService API#

Method Signature Return Type Description
Config(MessageGlobalConfig config) void Configure global message options
Destroy() void
Error(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) void Show error message
ErrorAsync(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show error message asynchronously
Info(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) void Show info message
InfoAsync(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show info message asynchronously
Loading(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) void Show loading message
LoadingAsync(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show loading message asynchronously
Open(MessageConfig config) void Open message with provided configuration
OpenAsync(MessageConfig config) Task Open message with provided configuration asynchronously
Success(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) void Show success message
SuccessAsync(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show success message asynchronously
Warning(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) void Show warning message
WarningAsync(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show warning message asynchronously

MessageConfig API#

Property Description Type Default Value
Content Content for message OneOf<String, RenderFragment> --
Duration Time before auto-dismiss, in seconds Double? --
Icon Icon for message RenderFragment --
Key Unique identifier for component String --
Type Style of message MessageType --
WaitForAnimation Whether to wait for animation completion when awaited externally Boolean --
OnClose Callback executed on close of message --
文档已更新,请点击 此处 更新。
A new version of this app is available. Click here to update.