Skip to content

useToast

Toast trigger, paired with a single root-mounted LxToastHost (component usage and live demo on the Toast component page).

Usage

ts
import { useToast } from '@luxeanor/ui'

const toast = useToast()
toast.success('Saved')
toast.error('Network error')
toast.show('warning', 'Quota almost used up', 6000)  // custom duration

API

MethodSignatureDescription
show(type: ToastType, message: string, duration = 3000) => voidgeneric trigger
success / error / info / warning(message: string) => voidsemantic shortcuts (3s)

ToastType = 'success' | 'error' | 'info' | 'warning'

Behavior & boundaries:

  • State is a module-level ref rendered by LxToastHostnothing shows if the host isn't mounted
  • Auto-dismisses; no manual close API
  • No-op under SSR: the server process is shared across requests, so writing module state would leak to other users; LxToastHost also renders nothing in SSR output (mounted guard)