跳至正文

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

属性类型默认值说明
childrenReactNode—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.
asElementType"span"Native element or component used for the root.
classNamestring—应用于根元素的类名。
styleCSSProperties—Native root styles.
refRef<HTMLElement>—Ref forwarded to the rendered root element.
renderReactElement | ((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
本页由机器翻译,尚未经人工审核。