Skip to content

API

Programmier‑API und Typen für @stratton-cologne/vue-smart-toast.

useToast()

ts
import { useToast } from '@stratton-cologne/vue-smart-toast'
const { toasts, showToast, removeToast } = useToast()
  • toasts: Toast[] – reaktives Array aktueller Toasts
  • showToast(opts: ToastOptions) – Toast erstellen/aktualisieren (per key upserten)
  • removeToast(id: number) – Toast schließen

Typen

ts
type ToastType = 'success' | 'info' | 'warning' | 'danger' | 'error' |
  'fuchsia' | 'slate' | 'lime' | 'red' | 'orange' | 'cyan' | 'gray' | 'dark'

type ToastPosition = 'top-left' | 'top-center' | 'top-right' |
  'bottom-left' | 'bottom-center' | 'bottom-right' | 'center' | 'center-left' | 'center-right'

interface ToastOptions {
  key?: string
  message: string
  type?: ToastType
  duration?: number
  position?: ToastPosition
}

Hinweis: error wird intern zu danger normalisiert.