Skip to content

Message Component ​

Message Component

Message component is used to display operation feedback or system prompts on the page, supporting multiple message types and styles, can automatically disappear or be manually closed, and is a lightweight feedback method.

Basic Usage ​

Basic message prompts, including four types: success, warning, info, and error.

The message component provides four different types for feedback in different scenarios.

Show CodeArrow
CopyGitHub

Message Style ​

You can customize the message width, padding, icon, and plain style.

The message component supports custom styles, such as width, padding, icon and plain style.

Show CodeArrow
CopyGitHub

Notification Type ​

Supports notification message display in four directions, can include title and content.

Message notification supports popup in four directions, suitable for scenarios that require stronger prompt effects.

Popup Position

Notification Type

Show CodeArrow
CopyGitHub

Close Configuration ​

Supports multiple closing methods including manual close, auto close, and close by pressing ESC key.

Message supports multiple closing methods configuration, including manual close, ESC key close and auto close.

Tips:

  • Manual Close: Set duration: 0 and isClose: true to display permanently and close manually
  • ESC Key Close: Set closeOnPressEscape: true to enable ESC key close function
  • Auto Close: Set duration to specified milliseconds to achieve auto close
Show CodeArrow
CopyGitHub

Custom Configuration ​

You can customize the message mount position and display position.

The message component supports custom mount container and display position.

Custom Mount Container

Specify the DOM node where the message is mounted by setting the appendTo property

Custom mount container, messages will be displayed here

Custom Display Position

Specify the display coordinates of the message by setting the custom property

Show CodeArrow
CopyGitHub

Event Handling ​

Message provides close callback events and supports stacked display of multiple messages.

The message component provides close callback events and supports multiple message stacking display.

Close Callback

Multiple Message Stacking

Show CodeArrow
CopyGitHub

Message API ​

Message Methods ​

Method NameDescriptionParametersReturn Value
TMessage.messageDisplay normal message(content: string, type?: string, options?: object) => stringUnique ID of message instance
TNotification.messageDisplay notification message(title: string, content: string, type?: string, options?: object) => stringUnique ID of message instance

Message Configuration ​

AttributeDescriptionTypeAccepted ValuesDefault
typeMessage typestringsuccess / warning / info / dangerinfo
plainWhether to use plain stylebooleantrue / falsefalse
messageTypeMessage display modestringdefault / noticedefault
titleTitle (available in notification mode)string——
positionPosition (available in notification mode)stringtopRight / bottomRight / bottomLeft / topLefttopRight
contentMessage contentstring——
iconIcon typestring—Auto-selected by type
durationDisplay duration (ms)number—2600
radiusBorder radius sizearray / number—[6, 6, 6, 6]
paddingPadding sizearray / number—[8, 12, 8, 12]
widthMessage box widthstring——
appendToTarget position for message renderingstring / element—body
customCustom position coordinatesobject {x: string, y: string}—{x: "50%", y: "24px"}
maxLengthMaximum number of messagesnumber—8
isCloseWhether to show close buttonbooleantrue / falsefalse
closeCallbackClose callback functionfunction(id: string)——
closeOnPressEscapeWhether to support ESC key closebooleantrue / falsetrue

Events ​

Event NameDescriptionCallback Parameters
closeTriggered when message closes(id: string)
clickTriggered when message is clicked(event: MouseEvent)

Slots ​

Slot NameDescription
defaultMessage content
iconCustom icon
closeCustom close button

Methods ​

Method NameDescriptionParameters
closeMessageClose message—

Style Variables ​

The message component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$theme-color-primaryTheme color - Primary
$theme-color-successTheme color - Success
$theme-color-infoTheme color - Info
$theme-color-warningTheme color - Warning
$theme-color-dangerTheme color - Danger
$color-whiteWhite color
$bg-color-defaultDefault background color
$bg-color-modelModal background color
$text-color-defaultDefault text color
$z-index-upUpper layer z-index

Released under the MIT License