logoAnt Design

⌘ K
  • 设计
  • 研发
  • 组件
  • 博客
  • 资源
  • 国内镜像
5.20.6
  • 组件总览
  • 通用
    • Button
      按钮
    • FloatButton
      悬浮按钮
      5.0.0
    • Icon
      图标
    • Typography
      排版
  • 布局
    • Divider
      分割线
    • Flex
      弹性布局
      5.10.0
    • Grid
      栅格
    • Layout
      布局
    • Space
      间距
  • 导航
    • Anchor
      锚点
    • Breadcrumb
      面包屑
    • Dropdown
      下拉菜单
    • Menu
      导航菜单
    • Pagination
      分页
    • Steps
      步骤条
  • 数据录入
    • AutoComplete
      自动完成
    • Cascader
      级联选择
    • Checkbox
      多选框
    • ColorPicker
      颜色选择器
      5.5.0
    • DatePicker
      日期选择框
    • Form
      表单
    • Input
      输入框
    • InputNumber
      数字输入框
    • Mentions
      提及
    • Radio
      单选框
    • Rate
      评分
    • Select
      选择器
    • Slider
      滑动输入条
    • Switch
      开关
    • TimePicker
      时间选择框
    • Transfer
      穿梭框
    • TreeSelect
      树选择
    • Upload
      上传
  • 数据展示
    • Avatar
      头像
    • Badge
      徽标数
    • Calendar
      日历
    • Card
      卡片
    • Carousel
      走马灯
    • Collapse
      折叠面板
    • Descriptions
      描述列表
    • Empty
      空状态
    • Image
      图片
    • List
      列表
    • Popover
      气泡卡片
    • QRCode
      二维码
      5.1.0
    • Segmented
      分段控制器
    • Statistic
      统计数值
    • Table
      表格
    • Tabs
      标签页
    • Tag
      标签
    • Timeline
      时间轴
    • Tooltip
      文字提示
    • Tour
      漫游式引导
      5.0.0
    • Tree
      树形控件
  • 反馈
    • Alert
      警告提示
    • Drawer
      抽屉
    • Message
      全局提示
    • Modal
      对话框
    • Notification
      通知提醒框
    • Popconfirm
      气泡确认框
    • Progress
      进度条
    • Result
      结果
    • Skeleton
      骨架屏
    • Spin
      加载中
    • Watermark
      水印
      5.1.0
  • 其他
    • Affix
      固钉
    • App
      包裹组件
      5.1.0
    • ConfigProvider
      全局化配置
    • Util
      工具类
      5.13.0

Badge
徽标数

图标右上角的圆形徽标数字。
使用import{ Badge }from"antd";
源码components/badge
文档编辑此页

相关资源

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-首页模板集
Scaffolds-脚手架市场
Umi-React 应用开发框架
dumi-组件/文档研发工具
qiankun-微前端框架
ahooks-React Hooks 库
Ant Motion-设计动效
国内镜像站点 🇨🇳

社区

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design 语雀专栏
Ant Design 知乎专栏
体验科技专栏
seeconf logoSEE Conf-蚂蚁体验科技大会
加入我们

帮助

GitHub
更新日志
常见问题
报告 Bug
议题
讨论区
StackOverflow
SegmentFault

Ant XTech logo更多产品

yuque logo语雀-构建你的数字花园
AntV logoAntV-数据可视化解决方案
Egg logoEgg-企业级 Node.js 框架
Kitchen logoKitchen-Sketch 工具集
Galacean logoGalacean-互动图形解决方案
xtech logo蚂蚁体验科技
主题编辑器
Made with ❤ by
蚂蚁集团和 Ant Design 开源社区
loading

何时使用

一般出现在通知图标或头像的右上角,用于显示需要处理的消息条数,通过醒目视觉形式吸引用户处理。

代码演示

5
0
基本

简单的徽章展示,当 count 为 0 时,默认不显示,但是可以使用 showZero 修改为显示。

codepen icon
External Link Icon
expand codeexpand code
99
99+
10+
999+
封顶数字

超过 overflowCount 的会显示为 ${overflowCount}+,默认的 overflowCount 为 99。

codepen icon
External Link Icon
expand codeexpand code
5
动态

展示动态变化的效果。

codepen icon
External Link Icon
expand codeexpand code
5
自定义位置偏移

设置状态点的位置偏移,格式为 [left, top],表示状态点距默认位置左侧、上方的偏移量。

codepen icon
External Link Icon
expand codeexpand code

Success
Error
Default
Processing
Warning
状态点

用于表示状态的小圆点。

codepen icon
External Link Icon
expand codeexpand code
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
缎带

使用缎带型的徽标。

codepen icon
External Link Icon
expand codeexpand code
11
25
99+
独立使用

不包裹任何元素即是独立使用,可自定样式展现。

在右上角的 badge 则限定为红色。

codepen icon
External Link Icon
expand codeexpand code
Link something
讨嫌的小红点

没有具体的数字。

codepen icon
External Link Icon
expand codeexpand code
5
可点击

用 a 标签进行包裹即可。

codepen icon
External Link Icon
expand codeexpand code
5
5
大小

可以设置有数字徽标的大小。

codepen icon
External Link Icon
expand codeexpand code
Presets
pink
red
yellow
orange
cyan
green
blue
purple
geekblue
magenta
volcano
gold
lime
Custom
#f50
rgb(45, 183, 245)
hsl(102, 53%, 61%)
hwb(205 6% 9%)
多彩徽标

我们添加了多种预设色彩的徽标样式,用作不同场景使用。如果预设值不能满足你的需求,可以设置为具体的色值。

codepen icon
External Link Icon
expand codeexpand code

API

通用属性参考:通用属性

Badge

参数说明类型默认值版本
color自定义小圆点的颜色string-
count展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时隐藏ReactNode-
classNames语义化结构 classRecord<SemanticDOM, string>-5.7.0
dot不展示数字,只有一个小红点booleanfalse
offset设置状态点的位置偏移[number, number]-
overflowCount展示封顶的数字值number99
showZero当数值为 0 时,是否展示 Badgebooleanfalse
size在设置了 count 的前提下有效,设置小圆点的大小default | small--
status设置 Badge 为状态点success | processing | default | error | warning-
styles语义化结构 styleRecord<SemanticDOM, CSSProperties>-5.7.0
text在设置了 status 的前提下有效,设置状态点的文本ReactNode-
title设置鼠标放在状态点上时显示的文字string-

Badge.Ribbon

参数说明类型默认值版本
color自定义缎带的颜色string-
placement缎带的位置,start 和 end 随文字方向(RTL 或 LTR)变动start | endend
text缎带中填入的内容ReactNode-

Semantic DOM

5
  • root
    5.7.0
    根节点
  • indicator
    5.7.0
    指示器节点

主题变量(Design Token)

组件 Token如何定制?

Token 名称描述类型默认值
dotSize点状徽标尺寸number6
indicatorHeight徽标高度string | number20
indicatorHeightSM小号徽标高度string | number14
indicatorZIndex徽标 z-indexstring | numberauto
statusSize状态徽标尺寸number6
textFontSize徽标文本尺寸number12
textFontSizeSM小号徽标文本尺寸number12
textFontWeight徽标文本粗细string | numbernormal

全局 Token如何定制?