Toast
Lightweight notifications and transient feedback
Toast
Lightweight notifications (similar to shadcn/sonner). Mount a single <TxToastHost /> at the app root, then call toast() anywhere.
Basic Usage
Toast
Mount host once, then trigger toasts.
Demo will load when visible.
API
toast(options)
toast({
id?: string
title?: string
description?: string
variant?: 'default' | 'success' | 'warning' | 'danger'
duration?: number // ms, 0 = no auto dismiss
})
Interaction Contract
<TxToastHost />renders a notification region withrole="region"andaria-label="Notifications".- Each toast includes a keyboard-focusable close button named
Dismiss notification. duration > 0auto-dismisses the toast;duration: 0keeps it visible untildismissToast(id)orclearToasts()is called.- Passing the same
idreplaces the existing toast, preventing duplicate stacked notifications for the same operation.
dismissToast / clearToasts
Import from @talex-touch/tuffex/utils:
import { dismissToast, clearToasts } from '@talex-touch/tuffex/utils'