Badge
Short label for a state, category, or count.
- 浏览器
- Chrome 123+Firefox 121+Safari 17.5+
- 层级
- 0
- 压缩后大小
- 201 B
- 强制布局预算
- 0 ms
- axe 预算
- 0
- 支持 SSR
- 是
- 公开契约
- 测试环境
交互示例
Badge
Ready示例
Status labels
Use visible words to convey state; color is a supporting cue.
DraftReadyReviewBlocked
import { Badge } from "@gunkin/uiify";
export default function Example() {
return (
<>
<Badge variant="secondary">Draft</Badge>
<Badge variant="success">Ready</Badge>
<Badge variant="warning">Review</Badge>
<Badge variant="destructive">Blocked</Badge>
</>
);
}API
Badge
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
children | ReactNode | — | Text shown inside the badge. |
variant | "secondary" | "success" | "warning" | "destructive" | — | Visual meaning written to data-variant; keep status understandable in text. |
size | "sm" | "md" | "lg" | — | Visual scale written to data-size; omitted when unset. |
as | ElementType | "span" | Native element or component used for the root. |
className | string | — | 应用于根元素的类名。 |
style | CSSProperties | — | Native root styles. |
ref | Ref<HTMLElement> | — | Ref forwarded to the rendered root element. |
render | ReactElement | ((props, state) => ReactElement) | — | 替换渲染元素,同时保留行为和无障碍连接关系。 |
键盘
| 按键 | 操作 |
|---|
无障碍
Static text marker with no role or keyboard behavior. Keep its meaning in visible words and do not use it as a control.
样式钩子
data-uiify-badgedata-variantdata-size