组件/Toast 提示
自 1.0.0BETA

Toast 提示

轻量通知与短暂状态反馈

该页面由 AI 迁移生成,请谨慎使用

内容已迁移完成,但仍建议结合源码和人工评审结果使用。

Toast 提示

轻量通知提示(类似 shadcn/sonner)。需要在应用根部挂载一次 <TxToastHost />,然后在任意位置调用 toast()

基础用法

Toast

挂载 host 后触发提示。

交互预览已暂停。

API

toast(options)

EXAMPLE.TS
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 导入:

EXAMPLE.TS
import { dismissToast, clearToasts } from '@talex-touch/tuffex/utils'