mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
70 lines
3.1 KiB
Markdown
70 lines
3.1 KiB
Markdown
---
|
||
category: Components
|
||
group: Feedback
|
||
title: Popconfirm
|
||
description: Pop up a bubble confirmation box for an action.
|
||
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*a7tqQ6wrdeAAAAAAAAAAAAAADrJ8AQ/original
|
||
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*iwYsQpeFcB0AAAAAAAAAAAAADrJ8AQ/original
|
||
demo:
|
||
cols: 2
|
||
---
|
||
|
||
## When To Use
|
||
|
||
A simple and compact dialog used for asking for user confirmation.
|
||
|
||
The difference with the `confirm` modal dialog is that it's more lightweight than the static popped full-screen confirm modal.
|
||
|
||
## Examples
|
||
|
||
<!-- prettier-ignore -->
|
||
<code src="./demo/basic.tsx">Basic</code>
|
||
<code src="./demo/locale.tsx">Locale text</code>
|
||
<code src="./demo/placement.tsx">Placement</code>
|
||
<code src="./demo/shift.tsx" iframe="300">Auto Shift</code>
|
||
<code src="./demo/dynamic-trigger.tsx">Conditional trigger</code>
|
||
<code src="./demo/icon.tsx">Customize icon</code>
|
||
<code src="./demo/async.tsx">Asynchronously close</code>
|
||
<code src="./demo/promise.tsx">Asynchronously close on Promise</code>
|
||
<code src="./demo/render-panel.tsx" debug>_InternalPanelDoNotUseOrYouWillBeFired</code>
|
||
<code src="./demo/wireframe.tsx" debug>Wireframe</code>
|
||
|
||
## API
|
||
|
||
Common props ref:[Common props](/docs/react/common-props)
|
||
|
||
| Param | Description | Type | Default value | Version |
|
||
| --- | --- | --- | --- | --- |
|
||
| cancelButtonProps | The cancel button props | [ButtonProps](/components/button/#api) | - | |
|
||
| cancelText | The text of the Cancel button | string | `Cancel` | |
|
||
| disabled | Whether show popconfirm when click its childrenNode | boolean | false | |
|
||
| icon | Customize icon of confirmation | ReactNode | <ExclamationCircle /> | |
|
||
| okButtonProps | The ok button props | [ButtonProps](/components/button/#api) | - | |
|
||
| okText | The text of the Confirm button | string | `OK` | |
|
||
| okType | Button `type` of the Confirm button | string | `primary` | |
|
||
| showCancel | Show cancel button | boolean | true | 4.18.0 |
|
||
| title | The title of the confirmation box | ReactNode \| () => ReactNode | - | |
|
||
| description | The description of the confirmation box title | ReactNode \| () => ReactNode | - | 5.1.0 |
|
||
| onCancel | A callback of cancel | function(e) | - | |
|
||
| onConfirm | A callback of confirmation | function(e) | - | |
|
||
| onPopupClick | A callback of popup click | function(e) | - | 5.5.0 |
|
||
|
||
Consult [Tooltip's documentation](/components/tooltip/#api) to find more APIs.
|
||
|
||
## Design Token
|
||
|
||
<ComponentTokenTable component="Popconfirm"></ComponentTokenTable>
|
||
|
||
## FAQ
|
||
|
||
### Why does the warning `findDOMNode is deprecated` sometimes appear in strict mode?
|
||
|
||
This is due to the implementation of `rc-trigger`. `rc-trigger` forces children to accept ref, otherwise it will fall back to findDOMNode, so children need to be native html tags. If not, you need to use `React.forwardRef` transparently passes `ref` to native html tags.
|
||
|
||
- `findDOMNode is deprecated` reproduce: <https://codesandbox.io/p/sandbox/finddomnode-c5hy96>
|
||
- Using `forwardRef` to fix: <https://codesandbox.io/p/sandbox/no-finddomnode-warning-forked-gdxczs>
|
||
|
||
## Note
|
||
|
||
Please ensure that the child node of `Popconfirm` accepts `onMouseEnter`, `onMouseLeave`, `onFocus`, `onClick` events.
|