通知

用于产品反馈和活动的灵活浮动消息 - 六个视口位置以及一个组件中的信息、成功、错误、自定义图标、头像、操作按钮和定时自动关闭变体。

Katherine Moss

凯瑟琳·莫斯

2 mins ago

我已完成添加笔记。很高兴我们随时为您提供审核!

安装

您可以使用我们的 CLI 或手动添加通知组件:

已支持深色模式,此 组件 会自动使用 BoardUI 的语义设计变量。 设置主题切换.

CLI 将组件源(及其内部依赖项)复制到您的项目中并安装任何所需的 npm 包。

npx boardui@latest add notification

使用共享 UI 包或自定义导入别名? 配置您的安装路径 在运行 CLI 之前。复制粘贴示例使用默认导入。

状态

套装 status 信息、成功或错误。每个状态都提供语义活动区域角色、默认图标和强调色。

新版本可用

刷新以开始使用最新的仪表盘更新。

更改已保存

您的工作区设置已更新。

<Notification status="information" title="New version available" description="Refresh to start using the latest dashboard updates."/> <Notification status="success" title="Changes saved" description="Your workspace settings have been updated."/> <Notification status="error" title="Upload failed" description="Check the file size and try again."/>

图标和头像

传递任何 Remix 图标 图标,或将图标替换为 avatar。头像通知可以显示在线、忙碌或离线状态。

自定义图标

使用任何 Remix 图标,同时保留选定的状态颜色。

Livia Saris

利维娅·萨里斯

just now

在启动清单中提到了您。

import { RiSparklingFill } from "@remixicon/react"; {/* Custom icon */}<Notification icon={RiSparklingFill} title="Custom icon" description="Use any Remix icon."/> {/* Avatar with presence */}<Notification avatar={{ src: "/avatars/livia-saris.webp", alt: "Livia Saris", presence: "busy", }} title="Livia Saris" timestamp="just now" description="Mentioned you in the launch checklist."/>

操作按钮

的 actions array 呈现小型 BoardUI 按钮并支持主要、次要和危险变体。

备份准备就绪

您最新的工作区备份已可供下载。

<Notification status="information" title="Backup ready" description="Your latest workspace backup is ready to download." actions={[ { label: "Not now", variant: "secondary", onClick: dismiss }, { label: "Download", variant: "primary", onClick: download }, ]}/>

职位

使用 position 支撑 NotificationViewport 将堆栈锚定到浏览器视口的任何角落或水平中心。

import { Notification, NotificationViewport,} from "@/components/base/notification/notification"; <NotificationViewport position="top-center"> <Notification status="information" title="New version available" description="Refresh to start using the latest dashboard updates." /></NotificationViewport> {/* Available positions: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right */}

定时解雇

套装 autoDismissDuration 以毫秒为单位显示同步的 3px 倒计时栏,并在倒计时达到零时关闭通知。使用 NotificationViewport 将重复的通知传送到浏览器视口边缘的平滑动画堆栈。

const [notifications, setNotifications] = useState([]); function showNotification(variant) { setNotifications((current) => [ ...current, { id: crypto.randomUUID(), variant }, ]);} <Button onClick={() => showNotification("success")}>Replay notification</Button><Button onClick={() => showNotification("information")}>Information</Button><Button onClick={() => showNotification("error")}>Error</Button><Button onClick={() => showNotification("avatar")}>With avatar</Button><Button onClick={() => showNotification("actions")}>With buttons</Button> <NotificationViewport> {notifications.map((notification) => ( <Notification {...variants[notification.variant]} key={notification.id} autoDismissDuration={2500} introDelay={0} onDismiss={() => setNotifications((current) => current.filter((item) => item.id !== notification.id) ) } /> ))}</NotificationViewport>