API Reference

Toastex exposes a simple, heavily typed API. Below are the available methods and interfaces.

Methods

  • Toastex.success(message: string, options?: ToastexOptions)
  • Toastex.error(message: string, options?: ToastexOptions)
  • Toastex.info(message: string, options?: ToastexOptions)
  • Toastex.warning(message: string, options?: ToastexOptions)
  • Toastex.show(options: ToastexOptions | string)
  • Toastex.config(options: ToastexGlobalConfig)

ToastexOptions Interface

PropertyTypeDescription
titlestringOptional title for the toast.
messagestringThe main text content.
typeToastType'success' | 'error' | 'warning' | 'info' | 'default'
themeToastTheme'light' | 'dark'
variantstring'default' | 'swift' | 'chat' | 'minimal' | 'outline' | 'liquid-glass' | 'liquid-chat'
positionToastPositione.g. 'top-right', 'bottom-center'
durationnumberDuration in seconds. Use 0 to disable auto-close. Default is 5.
soundbooleanWhether to play a sound effect.
logoUrlstringURL for a custom avatar (useful in chat variant).
avatarUrlstringLarge avatar image URL (specifically for liquid-chat).
appIconUrlstringSmall app icon overlaid on avatar (specifically for liquid-chat).
subtitlestringSecondary title text (specifically for liquid-chat).
timestringTimestamp text, e.g., 'now' (specifically for liquid-chat).