Skip to content

useMessage

Unified message prompt.

Parameters

NameTypeDefaultDescription
optionsMessageProps{}Message props. Reference ElementPlus Message Props

Returns

NameTypeDescription
successsuccess(message: string)Show success message
errorerror(message: string)Show error message
warningwarning(message: string)Show warning message
infoinfo(message: string)Show info message
closeAllcloseAll()Close all messages

Basic Usage

ts
import { useMessage } from '@vuecraft/components'

const { success, error, warning, info, closeAll } = useMessage()

success('Success message')
error('Error message')
warning('Warning message')
info('Info message')
closeAll()

Custom Usage

ts
import { useMessage } from '@vuecraft/components'

const { success, error, warning, info, closeAll } = useMessage({
  duration: 5000,
  showClose: false,
  plain: false,
  grouping: false,
})

success('Success message')
error('Error message')
warning('Warning message')
info('Info message')
closeAll()

Released under the MIT License.