瑚琏 Hulianv0.93.5413 组件0 组件
  • 开始
  • 组件
  • 区块
  • 页面
  • 模版
  • 更新
中文EN
  • 组件组件
  • 主题主题

浮层

  • 对话框
  • 命令式对话框
  • 确认对话框
  • 抽屉
  • 气泡卡片
  • 提示浮层
  • 悬停卡片
  • 链接预览
  • 视频弹层
  • 元素选择叠加层

提示

  • 提示条
  • 拦截卡
  • 文档提示框
  • 公告条
  • 命令式轻提示
  • 通知
  • 服务通知卡片
  • 结果页
  • 礼物连击
  • 飘心点赞
  • 气泡确认

加载与进度

  • 加载遮罩
  • 加载旋转器
  • 进度条

引导

  • 漫游引导

Notification

notification

在屏幕角落堆叠通知卡片,可带图标和操作

用法

五类型

notification.success / error / info / warning / open,派生左侧色条与默认图标。

tsx
notification.success({ title: "保存成功", description: "更改已同步。" });
notification.error({ title: "上传失败", description: "文件过大,请压缩后重试。" });
notification.info({ title: "系统通知", description: "维护窗口将于今晚开始。" });
notification.warning({ title: "空间不足", description: "剩余容量低于 10%。" });

带操作按钮 + 常驻

btn 槽放操作按钮,duration=0 时不自动关闭。

tsx
notification.open({
  title: "收到一条好友请求",
  description: "来自 设计部·小琏",
  duration: 0,
  btn: <Button size="sm">查看</Button>,
});

四角位置

placement 指定弹出位置:topRight / topLeft / bottomRight / bottomLeft。

tsx
notification.info({ title: "提示", description: "弹在指定角落", placement: "bottomLeft" });

何时用

需要在四角弹出带标题+描述+操作按钮的较重通知卡片时用(比如「收到好友请求 / 上传失败可重试」)。比 Toast 信息量大、可常驻、可带操作;只需一行短反馈、自动消失时用 Toast。命令式调用,无需在 JSX 里挂节点(但 NotificationProvider 须由 layout 单挂一次)。

导入

ts
import { notification, NotificationProvider, hulianNotificationManager } from "@hulianui/ui"

Props

notification.success/error/info/warning/open(options) 接收 NotificationOptions:

名称类型默认说明
type"open"|"success"|"error"|"info"|"warning"-经方法名隐含(open 为中性无图标);派生左侧色条 + 默认图标,token 取值同 Alert(info 走 --color-info,0.8.0 前借主色)
durationnumber4500自动关闭毫秒数;0 = 不自动关(常驻)
placement"topRight"|"topLeft"|"bottomRight"|"bottomLeft""topRight"弹出位置(四角)

调用返回 NotificationInstance,含 destroy(): void 立即关闭该通知。

Events

事件类型说明
onClose() => void关闭时回调(自动/手动/编程关闭均触发一次)

Slots

插槽类型说明
titleReactNode标题(加粗主行)
descriptionReactNode描述(次行,恒 text-muted-foreground)
iconReactNode自定义图标,覆盖默认(不传按类型派生)
btnReactNode操作区(按钮等),渲染在描述下方

禁忌 / 坑

  • NotificationProvider 须在 layout 单挂一次(同 Toast/Modal 范式),不要在每个调用点或 showcase 里挂 Provider,否则通知无处渲染。
  • duration: 0 才是常驻;不传 duration 默认 4500ms 自动关,需要用户必看的通知务必显式置 0。
  • 命令式触发的副作用通知,注意「触发即忘」的回调语义——onClose 仅保证触发一次,别在其中做依赖外部最新状态的操作。参见 [[fire-and-forget-side-effect-notification]]。

相关

Alert · Banner · Toast · ServiceMessage · Result · GiftFeed

Playground

notification.success({
  title: "操作成功",
  description: "数据已成功同步到云端。",
  placement: "topRight",
  duration: 4500,
})
上一个命令式轻提示反馈下一个服务通知卡片

本页

  • 用法
  • 文档
    • 何时用
    • 导入
    • Props
    • Events
    • Slots
    • 禁忌 / 坑
    • 相关
  • Playground