Tab
页签组件家族:TabBar 用于页面主导航,ButtonGroup 用于小范围切换视图。
TabBar
顶部页签导航,对应 Figma 「Page Tab」。3 种主色,可选 badge。
Import
import { TabBar, ButtonGroup } from "@forge-ui/react";Usage
通过 tabs 数组声明页签,active: true 标记当前选中项。
1<TabBar2 tabs={[3 { label: "Overview", active: true, badge: 3 },4 { label: "Analytics", badge: 12 },5 { label: "Reports" },6 { label: "Settings" },7 ]}8/>Colors
3 种主色:purple(默认)/ blue / black。
1<TabBar color="purple" tabs={tabs} />2<TabBar color="blue" tabs={tabs} />3<TabBar color="black" tabs={tabs} />With Badge
每个 tab 可单独传入 badge 数字,适合展示未读 / 计数。
1<TabBar2 tabs={[3 { label: "All", active: true, badge: 128 },4 { label: "Active", badge: 32 },5 { label: "Closed", badge: 96 },6 ]}7/>API
| Attribute | Type | Default | Description |
|---|---|---|---|
tabs | { label: string; active?: boolean; badge?: number }[] | — | 页签列表,active 为 true 的项高亮,badge 显示右上角数字。 |
color | 'purple' | 'blue' | 'black' | 'purple' | 选中态主色。 |
onChange | (index: number) => void | — | 切换页签回调,参数为下标。 |
className | string | — | 额外 className。 |