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

Alert
警告提示

警告提示,展现需要关注的信息。
使用import{ Alert }from"antd";
源码components/alert
文档编辑此页

相关资源

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

何时使用

  • 当某个页面需要向用户显示警告的信息时。
  • 非浮层的静态展现形式,始终展现,不会自动消失,用户可以点击关闭。

代码演示

Success Text
基本

最简单的用法,适用于简短的警告提示。

codepen icon
External Link Icon
expand codeexpand code
Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text

Error Text
Error Description Error Description Error Description Error Description Error Description Error Description

Error Text
Error Description Error Description Error Description Error Description Error Description Error Description
可关闭的警告提示

显示关闭按钮,点击可关闭警告提示。

codepen icon
External Link Icon
expand codeexpand code
Success Tips

Informational Notes

Warning

Error

Success Tips
Detailed description and advice about successful copywriting.

Informational Notes
Additional description and information about copywriting.

Warning
This is a warning notice about copywriting.

Error
This is an error message about copywriting.
图标

可口的图标让信息类型更加醒目。

codepen icon
External Link Icon
expand codeexpand code
轮播的公告

配合 react-text-loop-next 或 react-fast-marquee 实现消息轮播通知栏。

codepen icon
External Link Icon
expand codeexpand code
React 错误处理

友好的 React 错误处理 包裹组件。

codepen icon
External Link Icon
expand codeexpand code
Success Text

Info Text

Warning Text

Error Text
四种样式

共有四种样式 success、info、warning、error。

codepen icon
External Link Icon
expand codeexpand code
Success Text
Success Description Success Description Success Description

Info Text
Info Description Info Description Info Description Info Description

Warning Text
Warning Description Warning Description Warning Description Warning Description

Error Text
Error Description Error Description Error Description Error Description
含有辅助性文字介绍

含有辅助性文字介绍的警告提示。

codepen icon
External Link Icon
expand codeexpand code
顶部公告

页面顶部通告形式,默认有图标且 type 为 'warning'。

codepen icon
External Link Icon
expand codeexpand code
Alert Message Text

click the close button to see the effect

平滑地卸载

平滑、自然的卸载提示。

codepen icon
External Link Icon
expand codeexpand code
Success Tips

Error Text
Error Description Error Description Error Description Error Description

Warning Text

Info Text
Info Description Info Description Info Description Info Description
操作

可以在右上角自定义操作项。

codepen icon
External Link Icon
expand codeexpand code

API

通用属性参考:通用属性

参数说明类型默认值版本
action自定义操作项ReactNode-4.9.0
afterClose关闭动画结束后触发的回调函数() => void-
banner是否用作顶部公告booleanfalse
closable可关闭配置,>=5.15.0: 支持 aria-*boolean | ({ closeIcon?: React.ReactNode } & React.AriaAttributes)false
description警告提示的辅助性文字介绍ReactNode-
icon自定义图标,showIcon 为 true 时有效ReactNode-
message警告提示内容ReactNode-
showIcon是否显示辅助图标booleanfalse,banner 模式下默认值为 true
type指定警告提示的样式,有四种选择 success、info、warning、errorstringinfo,banner 模式下默认值为 warning
onClose关闭时触发的回调函数(e: MouseEvent) => void-

Alert.ErrorBoundary

参数说明类型默认值版本
description自定义错误内容,如果未指定会展示报错堆栈ReactNode{{ error stack }}
message自定义错误标题,如果未指定会展示原生报错信息ReactNode{{ error }}

Design Token

组件 Token如何定制?

Token 名称描述类型默认值
defaultPadding默认内间距undefined | Padding<string | number>8px 12px
withDescriptionIconSize带有描述时的图标尺寸number24
withDescriptionPadding带有描述的内间距undefined | Padding<string | number>20px 24px

全局 Token如何定制?