指标卡片

仪表盘标题的 KPI 卡有两种外观 - 仪表盘模板使用的紧凑行,以及带有渐变图标图块的页脚变体、可选信息工具提示、显示大小值以及带有比较标题和增量胶囊的页脚带。

总收入

$152,313.92

从上个月开始

16%

订单总数

25,162

从上个月开始

20%

新客户

3,847

从上个月开始

8.1%

退款

$4,209.44

从上个月开始

2.4%

安装

您可以使用我们的 CLI 或手动添加统计卡。 CLI 还提取它们组成的标签和工具提示原语:

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

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

npx boardui@latest add stat-cards

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

变体

两种外观通过 variant 属性。 plain (默认)是仪表盘模板中的紧凑卡 - 中性图标图块、标签、值和 Delta 标签。 页脚 标签旁边有一个有色渐变图标图块,将值设置为显示大小,然后将比较移动到带有白色 Delta 胶囊的页脚带,其字形如下 deltaColor.

客户

14,592

+5.3%

已售单位

385

-2.1%
<StatCards /> {/* compact: icon, label, value, delta chip */}<StatCards variant="footer" /> {/* icon tile + label, display value, footer band */}

带上你自己的数据

通行证 stats 替换演示指标。页脚变体读取每个统计数据的三个额外可选字段: tone 为图标图块着色(蓝色、橙色、紫色、粉色、天空或翠绿色), caption 交换页脚文本,并且 hint 添加带有工具提示的信息字形。

import { RiCoinsFill, RiShoppingBasket2Fill } from "@remixicon/react";import { StatCards, type Stat } from "@/components/application/dashboard/stat-cards"; const stats: Stat[] = [ { icon: RiCoinsFill, label: "Total revenue", value: "$152,313.92", delta: "16%", deltaColor: "lime", // lime | rose | neutral - picks the pill glyph too tone: "blue", // icon tile tint (footer variant) caption: "From last month", // footer band caption (footer variant) hint: "Gross revenue across all channels.", // info tooltip (footer variant) }, { icon: RiShoppingBasket2Fill, label: "Total orders", value: "25,162", delta: "20%", deltaColor: "lime", tone: "orange", },]; <StatCards variant="footer" stats={stats} />