Toast 提示
轻量通知与短暂状态反馈
Toast 提示
轻量通知提示(类似 shadcn/sonner)。需要在应用根部挂载一次 <TxToastHost />,然后在任意位置调用 toast()。
基础用法
Toast
挂载 host 后触发提示。
交互预览已暂停。
API
toast(options)
toast({
id?: string
title?: string
description?: string
variant?: 'default' | 'success' | 'warning' | 'danger'
duration?: number // ms, 0 = 不自动关闭
})
交互契约
<TxToastHost />渲染为role="region"、aria-label="Notifications"的通知区域。- 每条 toast 都带可键盘聚焦的关闭按钮,按钮名称为
Dismiss notification。 duration > 0时自动关闭,duration: 0时保持显示直到调用dismissToast(id)或clearToasts()。- 传入相同
id会替换现有 toast,避免重复堆叠同一业务提示。
dismissToast / clearToasts
从 @talex-touch/tuffex/utils 导入:
import { dismissToast, clearToasts } from '@talex-touch/tuffex/utils'
Components