logoAnt Design

⌘ K
  • 设计
  • 研发
  • 组件
  • 博客
  • 资源
  • 国内镜像
YouMindTRACTIANLobeHubCodeRabbit
6.5.0
  • 组件总览
  • 更新日志
    v6.5.0
  • 通用
    • Button按钮
    • FloatButton悬浮按钮
    • Icon图标
    • Typography排版
  • 布局
    • Divider分割线
    • Flex弹性布局
    • Grid栅格
    • Layout布局
    • Masonry瀑布流
      6.0.0
    • Space间距
    • Splitter分隔面板
  • 导航
    • Anchor锚点
    • Breadcrumb面包屑
    • Dropdown下拉菜单
    • Menu导航菜单
    • Pagination分页
    • Steps步骤条
    • Tabs标签页
  • 数据录入
    • AutoComplete自动完成
    • Cascader级联选择
    • Checkbox多选框
    • ColorPicker颜色选择器
    • 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二维码
    • Segmented分段控制器
    • Statistic统计数值
    • Table表格
    • Tag标签
    • Timeline时间轴
    • Tooltip文字提示
    • Tour漫游式引导
    • Tree树形控件
  • 反馈
    • Alert警告提示
    • Drawer抽屉
    • Message全局提示
    • Modal对话框
    • Notification通知提醒框
    • Popconfirm气泡确认框
    • Progress进度条
    • Result结果
    • Skeleton骨架屏
    • Spin加载中
    • Watermark水印
  • 其他
    • Affix固钉
    • App包裹组件
    • BorderBeam边框流光
      6.4.0
    • ConfigProvider全局化配置
    • Util工具类
何时使用
代码演示
基本
独立使用
封顶数字
讨嫌的小红点
动态
可点击
自定义位置偏移
大小
状态点
多彩徽标
缎带
自定义语义结构的样式和类
API
Badge
Badge.Ribbon
Semantic DOM
Badge
Badge.Ribbon
主题变量(Design Token)

Badge
徽标数

图标右上角的圆形徽标数字。
使用import { Badge } from 'antd';
反馈
components/badge提交问题待解决
文档
编辑此页LLMs.md
Avatar头像Calendar日历

相关资源

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

社区

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

帮助

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

Ant XTech logo更多产品

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

何时使用

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

代码演示

API

通用属性参考:通用属性

Badge

参数说明类型默认值版本全局配置
color自定义小圆点的颜色string-×
count展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时隐藏ReactNode-×
classNames用于自定义组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-5.7.0
dot不展示数字,只有一个小红点booleanfalse×
offset设置状态点的位置偏移[number, number]-×
overflowCount展示封顶的数字值number99×
showZero当数值为 0 时,是否展示 Badgebooleanfalse×
size在设置了 count 的前提下有效,设置小圆点的大小medium | small--×
status设置 Badge 为状态点success | processing | default | error | warning-×
styles用于自定义组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-5.7.0
text在设置了 status 的前提下有效,设置状态点的文本ReactNode-×
title设置鼠标放在状态点上时显示的文字。设置为 null 或 false 时移除原生 tooltipstring | null | false-6.5.0×

Badge.Ribbon

参数说明类型默认值版本全局配置
classNames用于自定义组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
color自定义缎带的颜色string-×
placement缎带的位置,start 和 end 随文字方向(RTL 或 LTR)变动start | endend×
styles用于自定义组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-6.0.0
text缎带中填入的内容ReactNode-×

Semantic DOM

Badge

5
  • root
    5.7.0
    根元素,包含相对定位、行内块布局、适应内容宽度等基础布局样式
  • indicator
    5.7.0
    指示器元素,包含定位、层级、尺寸、颜色、字体、文本对齐、背景、圆角、阴影、过渡动画等完整的徽标样式

Badge.Ribbon

Pushes open the window
and raises the spyglass.
Hippies
  • root
    6.0.0
    根元素,设置相对定位和包装容器样式
  • indicator
    6.0.0
    指示器元素,设置绝对定位、内边距、背景色、圆角和缎带样式
  • content
    6.0.0
    文本元素,设置文本颜色和缎带内容显示样式

主题变量(Design Token)

组件 Token如何定制?
Token 名称描述类型默认值
dotSize点状徽标尺寸number6
indicatorHeight徽标高度string | number20
indicatorHeightSM小号徽标高度string | number14
indicatorZIndex徽标 z-indexstring | numberauto
paddingInline多字符徽标水平内边距string | number8
statusSize状态徽标尺寸number6
textFontSize徽标文本尺寸number12
textFontSizeSM小号徽标文本尺寸number12
textFontWeight徽标文本粗细string | numbernormal
全局 Token如何定制?
Token 名称描述类型默认值
colorBorderBg控制元素背景边框的颜色。string#ffffff
colorError用于表示操作失败的 Token 序列,如失败按钮、错误状态提示(Result)组件等。string#ff4d4f
colorErrorHover错误色的深色悬浮态string#ff7875
colorInfo用于表示操作信息的 Token 序列,如 Alert 、Tag、 Progress 等组件都有用到该组梯度变量。string#1677ff
colorInfoTextHover信息色的文本悬浮态。string#4096ff
colorSuccess用于表示操作成功的 Token 序列,如 Result、Progress 等组件会使用该组梯度变量。string#52c41a
colorText最深的文本色。为了符合W3C标准,默认的文本颜色使用了该色,同时这个颜色也是最深的中性色。stringrgba(0,0,0,0.88)
colorTextLightSolid控制带背景色的文本,例如 Primary Button 组件中的文本高亮颜色。string#fff
colorTextPlaceholder控制占位文本的颜色。stringrgba(0,0,0,0.25)
colorWarning用于表示操作警告的 Token 序列,如 Notification、 Alert等警告类组件或 Input 输入类等组件会使用该组梯度变量。string#faad14
fontFamilyAnt Design 的字体家族中优先使用系统默认的界面字体,同时提供了一套利于屏显的备用字体库,来维护在不同平台以及浏览器的显示下,字体始终保持良好的易读性和可读性,体现了友好、稳定和专业的特性。string-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize设计系统中使用最广泛的字体大小,文本梯度也将基于该字号进行派生。number14
lineHeight文本行高number1.5714285714285714
lineWidth用于控制组件边框、分割线等的宽度number1
marginXS控制元素外边距,小尺寸。number8
motionDurationMid动效播放速度,中速。用于中型元素动画交互string0.2s
motionDurationSlow动效播放速度,慢速。用于大型元素如面板动画交互string0.3s
motionEaseOutBack预设动效曲率string
Cubic Bezier Visualizer
cubic-bezier(0.12, 0.4, 0.29, 1.46)External Link Icon
5
0
基本

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
99
99+
10+
999+
封顶数字

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5
动态

展示动态变化的效果。

CodeSandbox Icon
codepen icon
External Link Icon
Expand Icon
5
自定义位置偏移

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon

Success
Error
Default
Processing
Warning
状态点

用于表示状态的小圆点。

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
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
缎带

使用缎带型的徽标。

CodeSandbox Icon
codepen icon
External Link Icon
Expand Icon
11
25
99+
独立使用

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

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Link something
讨嫌的小红点

没有具体的数字。

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5
可点击

用 a 标签进行包裹即可。

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5
5
大小

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
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%)
多彩徽标

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

55
Card with custom ribbon
This card has a customized ribbon with semantic classNames and styles.
Custom Ribbon
Card with custom ribbon
This card has a customized ribbon with semantic classNames and styles.
Custom Ribbon
自定义语义结构的样式和类

通过 classNames 和 styles 传入对象/函数可以自定义 Badge 的语义化结构样式。

CodeSandbox Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Hitu Icon
Hitu Icon
CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Hitu Icon