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

Update message content with unique key.

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

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

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) Task Show error message
Info(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show info message
Loading(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show loading message
Open(MessageConfig config) Task Open message with provided configuration
Success(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show success message
Warning(OneOf<String, RenderFragment, MessageConfig> content, Double? duration, Action onClose) Task Show warning message

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 --
OnClose Callback executed on close of message --
Drawer Modal
文档已更新,请点击 此处 更新。
A new version of this app is available. Click here to update.