For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/zh/components/sonner.md.
v0.0.57
  • 简体中文
  • Sonner

    反馈@rockshin/tao-ui

    通过命令式 API 展示短暂 toast 通知、异步状态与操作反馈。

    何时使用

    操作结果不需要持续占据页面空间时使用 Sonner。

    推荐

    • 消息简短并说明结果。
    • 异步操作使用 loading 或 promise 生命周期。
    • 关键恢复操作可以提供 action。

    避免

    • 不要用 toast 承载必须阅读的长期信息。

    代码演示

    每组示例独立运行,通知只出现在当前预览内。复制到应用时通常只需挂载一个 Sonner。

    基础用法

    390 × 640
    TSX

    语义化彩色 Toast

    390 × 640
    TSX

    加载与 Promise 生命周期

    390 × 640
    TSX

    操作、位置与堆叠限制

    390 × 640
    TSX

    语义颜色

    richColors 为状态通知提供区分。

    390 × 640
    TSX

    通知操作

    action 与 cancel 提供相关操作。

    390 × 640
    TSX

    通知位置

    选择通知的显示位置,通知保留在预览窗口内。

    390 × 640
    TSX

    堆叠与数量上限

    visibleToasts 限制同时可见的通知数量。

    390 × 640
    TSX

    显示时长

    每条通知可以覆盖默认时长,常驻通知需要明确关闭入口。

    390 × 640
    TSX

    表单提交反馈

    本地延迟模拟提交,展示等待、成功和失败反馈。

    390 × 640
    TSX

    API

    Sonner

    属性说明类型默认值
    className节点类名string | undefined-
    style节点样式CSSProperties | undefined-

    toast

    属性说明类型默认值