Skip to content

KMessage ​

Display global messages as feedback in response to user operations.

Install ​

bash
pnpm add @ikun-ui/message
bash
yarn add @ikun-ui/message
bash
npm install @ikun-ui/message

Basic usage ​

Determine the display position by setting the placement option

Different emotion categories ​

Display different emotion category messages by calling different methods

TIP

The method of MessageInst.info/success/error/warning takes precedence over options.type.

Closable message ​

Through the options, you can set whether the message can be closed, the duration of existence, automatic close and close callback

message with offset ​

Sometimes you may need the message to be slightly offset by a distance in the y-axis direction

Update the message ​

Custom content ​

You can render content through slots

Message Options ​

NameTypeDefaultDescription
placement'right-top' / 'left-top' / 'right-bottom' / 'left-bottom'right-topWhere the message appears
closebooleanfalseWhether the message can be closed manually
autoClosebooleanfalseWhether the message is automatically closed
durationnumber3000Message's auto-close timing (only when autoClose = true) takes effect
onCloseIKunUncertainFunction-The callback method when the message is closed
type'info' / 'warning' 'error' / 'success'-The emotion category of the message
offsetnumber0Message is offset on the y-axis
titlestring / SvelteComponent-The title content of the message, which can be a html string or a svelte component
contentstring / SvelteComponent{}The content of the message, which can be a html string or a svelte component
clsstring-Additional class
attrsRecord<string, string>{}Additional attributes

Message Api ​

NameTypeDescription
KMessage<T>(options: MessageOptions<T>)=>MessageInstRender a message according to the incoming options and return the message instance
KMessage.info<T>(options: MessageOptions<T>)=>MessageInstRender a message of info type according to the incoming options and return the message instance
KMessage.warning<T>(options: MessageOptions<T>)=>MessageInstRender a message of warning type according to the incoming options and return the message instance
KMessage.success<T>(options: MessageOptions<T>)=>MessageInstRender a message of success type according to the incoming options and return the message instance
KMessage.error<T>(options: MessageOptions<T>)=>MessageInstRender a message of error type according to the incoming options and return the message instance
KMessage.update<T>(inst: typeof MessageInst, options: MessageOptions<T>)=>voidUpdate the specified message
KMessage.clearAll() => voidClear all messages
KMessage.clear(inst: typeof MessageInst) => voidClear the specified message

MIT Licensed