API Reference
TypeScript types
All public types are exported from the package root:
ts
import type {
ToastType, // 'info' | 'success' | 'warning' | 'error' | 'loading' | 'custom'
ToastPriority, // 'critical' | 'high' | 'normal' | 'low'
ToastPosition, // 'top-left' | 'top-center' | 'top-right' | 'bottom-*'
ToastOptions, // Full options object
ToastItem, // Internal reactive toast item (used in headless mode)
ToastAction, // { label: string; onClick: () => void }
ToastUndo, // { label?: string; onUndo: () => void | Promise<void>; duration?: number }
ToastDesignTokens, // All CSS token keys typed
PromiseToastMessages, // { loading, success, error }
ToastContext, // Isolated queue context
GlobalToastOptions, // Plugin / module options
ToastApi, // Return type of useToast()
} from 'vue-toast-kit'Working with ToastItem in headless mode:
ts
import type { ToastItem } from 'vue-toast-kit'
function renderCustomToast(t: ToastItem) {
// t.remaining.value — number 0–1
// t.isPaused.value — boolean
// t.groupCount.value — number
// t.options.type, t.options.priority, etc.
}Typed token override:
ts
import type { ToastDesignTokens } from 'vue-toast-kit'
const darkGlass: ToastDesignTokens = {
colorBg: 'rgba(15, 15, 20, 0.85)',
colorText: '#f0f0f0',
borderRadius: '14px',
shadow: '0 8px 32px rgba(0,0,0,0.6)',
}Advanced exports
The package root also exports a handful of lower-level building blocks — for advanced integrations (analytics, custom containers, framework-agnostic SSR handling) rather than everyday use:
| Export | Kind | Description |
|---|---|---|
ToastQueue | class | The engine behind every ToastContext — active/pending arrays, dedup/preempt/priority logic, and the onAdd/onDismiss/onUpdate events. See Event Emitter. |
UndoTimer | class | The countdown timer backing remaining/pause()/resume() on every ToastItem — start()/pause()/resume()/destroy(). See Architecture. |
GroupManager | class | Tracks which toasts are hidden behind a group leader and which groups are expanded — add()/remove()/toggleExpand()/isExpanded()/getGroupIds()/hasGroup()/clear(). |
globalBuffer | value (ToastBuffer) | The module-level SSR buffer instance every toast() call writes to on the server before <ToastContainer> mounts. See SSR compatibility. |
isServer | value (boolean) | typeof window === 'undefined', computed once at module load — what ToastContext.addToast() checks to decide buffer-vs-queue. |
PRIORITY_ORDER | value | Record<ToastPriority, number> — the numeric ranking (critical: 3 … low: 0) the queue sorts and preempts by. |
DEFAULT_OPTIONS | value | The base ToastOptions defaults every toast starts from, before GlobalToastOptions and per-toast options are layered on top. |
TOAST_CONTEXT_KEY | value (Symbol) | The provide/inject key useToastContext() reads. See Multi-Instance. |
GLOBAL_OPTIONS_KEY | value (Symbol) | The provide/inject key <ToastContainer> reads for its plugin/module-level position/theme/maxVisible defaults. See ToastContainer. |