mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 21:48:19 +08:00
86b5c50cb4
* chore: adjust doc * chore: simplify arrow offset * chore: auto adjust shift * docs: adjust demo * chore: update snapshot * chore: provide ref * test: prepare * chore: update deps * test: fix part test * test: fix part test * test: fix part test * test: fix part test * test: fix part test * test: update snapshot * fix: missing pure render * fix: Popover pure panel * test: update snapshot * test: update tour snapshot * chore: bump trigger ver * test: fix render ssr logic * test: skip unnecessary case * test: fix test case * test: update snapshot * test: update snapshot * test: update snapshot * test: update snapshot * test: update snapshot * test: fix test case * test: fix test case * chore: clean up useless warning * test: add check for placement * chore: ignore default
65 lines
3.3 KiB
Markdown
65 lines
3.3 KiB
Markdown
---
|
||
category: Components
|
||
subtitle: 文字提示
|
||
group: 数据展示
|
||
title: Tooltip
|
||
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*3u9eSZO_4c0AAAAAAAAAAAAADrJ8AQ/original
|
||
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*gwrhTozoTC4AAAAAAAAAAAAADrJ8AQ/original
|
||
demo:
|
||
cols: 2
|
||
---
|
||
|
||
简单的文字提示气泡框。
|
||
|
||
## 何时使用
|
||
|
||
鼠标移入则显示提示,移出消失,气泡浮层不承载复杂文本和操作。
|
||
|
||
可用来代替系统默认的 `title` 提示,提供一个 `按钮/文字/操作` 的文案解释。
|
||
|
||
## 代码演示
|
||
|
||
<!-- prettier-ignore -->
|
||
<code src="./demo/basic.tsx">基本</code>
|
||
<code src="./demo/placement.tsx">位置</code>
|
||
<code src="./demo/arrow.tsx">箭头展示</code>
|
||
<code src="./demo/shift.tsx" iframe="200">贴边偏移</code>
|
||
<code src="./demo/auto-adjust-overflow.tsx" debug>自动调整位置</code>
|
||
<code src="./demo/destroy-tooltip-on-hide.tsx" debug>隐藏后销毁</code>
|
||
<code src="./demo/colorful.tsx">多彩文字提示</code>
|
||
<code src="./demo/render-panel.tsx" debug>_InternalPanelDoNotUseOrYouWillBeFired</code>
|
||
|
||
## API
|
||
|
||
| 参数 | 说明 | 类型 | 默认值 |
|
||
| ----- | -------- | ---------------------------- | ------ |
|
||
| title | 提示文字 | ReactNode \| () => ReactNode | - |
|
||
|
||
### 共同的 API
|
||
|
||
以下 API 为 Tooltip、Popconfirm、Popover 共享的 API。
|
||
|
||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||
| --- | --- | --- | --- | --- |
|
||
| align | 该值将合并到 placement 的配置中,设置参考 [rc-tooltip](https://github.com/react-component/tooltip) | object | - | |
|
||
| arrow | 修改箭头的显示状态以及修改箭头是否指向目标元素中心 | boolean \| { arrowPointAtCenter: boolean } | true | 5.2.0 |
|
||
| autoAdjustOverflow | 气泡被遮挡时自动调整位置 | boolean | true | |
|
||
| color | 背景颜色 | string | - | 4.3.0 |
|
||
| defaultOpen | 默认是否显隐 | boolean | false | 4.23.0 |
|
||
| destroyTooltipOnHide | 关闭后是否销毁 Tooltip | boolean | false | |
|
||
| getPopupContainer | 浮层渲染父节点,默认渲染到 body 上 | (triggerNode: HTMLElement) => HTMLElement | () => document.body | |
|
||
| mouseEnterDelay | 鼠标移入后延时多少才显示 Tooltip,单位:秒 | number | 0.1 | |
|
||
| mouseLeaveDelay | 鼠标移出后延时多少才隐藏 Tooltip,单位:秒 | number | 0.1 | |
|
||
| overlayClassName | 卡片类名 | string | - | |
|
||
| overlayStyle | 卡片样式 | object | - | |
|
||
| overlayInnerStyle | 卡片内容区域的样式对象 | object | - | |
|
||
| placement | 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | `top` | |
|
||
| trigger | 触发行为,可选 `hover` \| `focus` \| `click` \| `contextMenu`,可使用数组设置多个触发行为 | string \| string\[] | `hover` | |
|
||
| open | 用于手动控制浮层显隐,小于 4.23.0 使用 `visible`([为什么?](/docs/react/faq#弹层类组件为什么要统一至-open-属性)) | boolean | false | 4.23.0 |
|
||
| zIndex | 设置 Tooltip 的 `z-index` | number | - | |
|
||
| onOpenChange | 显示隐藏的回调 | (open: boolean) => void | - | 4.23.0 |
|
||
|
||
## 注意
|
||
|
||
请确保 `Tooltip` 的子元素能接受 `onMouseEnter`、`onMouseLeave`、`onFocus`、`onClick` 事件。
|