Skip to content

Message ​

A lightweight toast notification that appears at the top of the page. Fully programmatic — no component needed in your template.

Basic ​

vue
<script setup>
import { VxMessage } from 'veloxui'

VxMessage('Default message')
VxMessage.success('Success message')
VxMessage.warning('Warning message')
VxMessage.danger('Danger message')
VxMessage.info('Info message')
</script>

Closable ​

Set closable: true to show a close button.

vue
VxMessage.success('File saved', { closable: true })

Plain Style ​

Use plain: true for a neutral background with colored icon and border.

vue
VxMessage.success('Saved successfully', { plain: true })

Loading ​

Use VxMessage.loading() for async operations. It stays visible until you close it manually.

vue
// Show loading, then swap to success
const handle = VxMessage.loading('Saving...')
await saveData()
handle.close()
VxMessage.success('Saved!')

// Or update in-place
const handle = VxMessage.loading('Uploading...')
await upload()
handle.update({ message: 'Upload complete!', type: 'success', duration: 2000 })

HTML Content ​

Set dangerouslyUseHTMLString: true to render HTML in the message.

vue
VxMessage({
  message: 'File <strong>report.pdf</strong> uploaded',
  type: 'success',
  dangerouslyUseHTMLString: true,
})

Action Button ​

Add an inline action button with action: { text, onClick }.

vue
VxMessage({
  message: 'Email archived',
  duration: 5000,
  action: {
    text: 'Undo',
    onClick: () => restoreEmail(),
  },
})

Progress Bar ​

Set showProgress: true to show a visual countdown.

vue
VxMessage.success('Auto-closing...', {
  showProgress: true,
  duration: 4000,
})

Custom Position ​

Messages can appear in 6 positions. Click any zone to preview.

vue
VxMessage.info('Top left', { position: 'top-left' })
VxMessage.success('Bottom right', { position: 'bottom-right' })

Without Icon ​

vue
VxMessage.success('No icon', { showIcon: false })

Custom Duration ​

Set duration in ms. Use 0 for a persistent message (requires closable).

vue
VxMessage.info('Quick', { duration: 1000 })
VxMessage.warning('Persistent', { duration: 0, closable: true })

Custom Icon ​

Pass a raw SVG string as the icon option.

vue
VxMessage({
  message: 'Rocket launched!',
  type: 'info',
  icon: '<svg ...>...</svg>',
})

Grouping ​

Use grouping: true to prevent duplicate messages with the same content.

vue
VxMessage.info('Only one shown', { grouping: true })

Update Existing ​

Use id to update a live message, or call update() on the handle.

vue
// Update by ID
VxMessage({ id: 'upload', message: 'Uploading...', type: 'loading' })
// Later...
VxMessage({ id: 'upload', message: 'Done!', type: 'success', duration: 2000 })

// Or via handle
const h = VxMessage.loading('Processing...')
h.update({ message: 'Complete!', type: 'success', duration: 2000 })

Max Count ​

Limit the number of visible messages per position using VxMessage.config().

vue
VxMessage.config({ max: 3 }) // only 3 visible at a time

Promise Support ​

Chain .then() to run code after the message closes.

vue
VxMessage.success('Step 1 complete', { duration: 2000 })
  .then(() => VxMessage.info('Moving to step 2...'))

Custom Style ​

Every visual property is overridable: background, color, iconColor, borderColor, borderRadius, shadow, progressColor.

vue
VxMessage({
  message: 'Fully customized',
  background: 'linear-gradient(135deg, #667eea, #764ba2)',
  color: '#fff',
  iconColor: '#fff',
  borderColor: 'transparent',
  borderRadius: '9999px',
  shadow: '0 4px 20px rgba(102,126,234,0.4)',
  progressColor: '#c4b5fd',
})

Close All ​

vue
VxMessage.closeAll()

API ​

VxMessage(options) ​

ParamTypeDefaultDescription
messagestring—Message text (or pass string directly)
type'success' | 'warning' | 'danger' | 'info' | 'loading' | 'default''default'Message type
durationnumber3000Auto-close in ms. 0 = no auto-close
closablebooleanfalseShow close button
showIconbooleantrueShow type icon
iconComponent | string—Custom icon (Vue component or SVG string)
plainbooleanfalseNeutral background with colored icon
position'top-center' | 'top-left' | 'top-right' | 'bottom-center' | 'bottom-left' | 'bottom-right''top-center'Position on screen
showProgressbooleanfalseVisual countdown bar
dangerouslyUseHTMLStringbooleanfalseRender message as HTML
action{ text: string, onClick: () => void }—Inline action button
idstring—Reuse/update an existing message
groupingbooleanfalsePrevent duplicate messages
offsetnumber16Distance from viewport edge
backgroundstring—Custom background (color, gradient)
colorstring—Custom text color
iconColorstring—Custom icon color
borderColorstring—Custom border color
progressColorstring—Custom progress bar color
borderRadiusstring—Custom border radius
shadowstring—Custom box-shadow
customClassstring—Extra CSS class
customStyleCSSStyleDeclaration—Inline style overrides
onClose() => void—Callback when message closes

Methods ​

ts
VxMessage.success(message, options?)
VxMessage.warning(message, options?)
VxMessage.danger(message, options?)
VxMessage.info(message, options?)
VxMessage.loading(message, options?)  // duration defaults to 0
VxMessage.closeAll()
VxMessage.config({ max: 3 })          // limit visible count

Return Value ​

ts
const handle = VxMessage.success('Done')
handle.close()                        // dismiss manually
handle.update({ message: 'Updated' }) // change content/type
handle.then(() => { /* ... */ })       // runs after close