> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt.

# Popconfirm

Feedback`@rockshin/tao-ui`

[Examples](#examples)[API](#api)

Shows a compact confirmation popup anchored to a trigger element, with OK and Cancel actions.

## When to use

Use Popconfirm for lightweight inline confirmations such as delete actions, where a full Modal would be too heavy. Use Modal.confirm for critical or complex confirmations.

**Recommended**

- Keep the title to one short question; put detail in the description.
- Use Popconfirm for reversible, low-risk actions anchored to the control that triggers them.

**Avoid**

- Do not use Popconfirm for irreversible high-risk operations; use Modal.confirm instead.
- Do not put forms or rich interactions inside a Popconfirm.

## Examples


### Basic usage
```tsx preview
import { useState } from 'react';
import { Button, Popconfirm } from '@rockshin/tao-ui';

function PopconfirmExample() {
  const [feedback, setFeedback] = useState('');
  return (
    <>
      <Popconfirm
        title="Delete this item?"
        description="This action cannot be undone."
        onConfirm={() => setFeedback('confirmed')}
      >
        <Button variant="destructive">Delete</Button>
      </Popconfirm>
      <output
        aria-live="polite"
        style={{
          display: 'block',
          marginTop: 12,
          whiteSpace: 'pre-wrap',
          overflowWrap: 'anywhere',
        }}
      >
        {feedback}
      </output>
    </>
  );
}

export default PopconfirmExample;
```

### Description and custom labels
```tsx preview
import { useState } from 'react';
import { Button, Popconfirm, Stack } from '@rockshin/tao-ui';

function PopconfirmVariants() {
  const [feedback, setFeedback] = useState('');
  return (
    <>
      <Stack direction="horizontal" gap="md">
        <Popconfirm
          title="Delete item?"
          description="This action cannot be undone."
          onConfirm={() => setFeedback('delete')}
        >
          <Button variant="destructive">Delete</Button>
        </Popconfirm>
        <Popconfirm
          title="Leave this page?"
          description="Unsaved changes will be lost."
          okText="Leave"
          cancelText="Stay"
          onConfirm={() => setFeedback('leave')}
        >
          <Button variant="secondary">Leave page</Button>
        </Popconfirm>
      </Stack>
      <output
        aria-live="polite"
        style={{
          display: 'block',
          marginTop: 12,
          whiteSpace: 'pre-wrap',
          overflowWrap: 'anywhere',
        }}
      >
        {feedback}
      </output>
    </>
  );
}

export default PopconfirmVariants;
```

### Button props and disabled state
```tsx preview
import { Button, Popconfirm, Stack } from '@rockshin/tao-ui';

function PopconfirmStates() {
  return (
    <Stack direction="horizontal" gap="md">
      <Popconfirm
        title="Archive project?"
        okButtonProps={{ loading: true }}
        cancelButtonProps={{ disabled: true }}
      >
        <Button variant="secondary">Loading confirm</Button>
      </Popconfirm>
      <Popconfirm title="Unavailable" disabled>
        <Button disabled>Disabled</Button>
      </Popconfirm>
    </Stack>
  );
}

export default PopconfirmStates;
```

### Confirm and cancel outcomes
Handle both callbacks and show the chosen outcome inline.
```tsx preview
import { useState } from 'react';
import { Popconfirm, Button, Stack } from '@rockshin/tao-ui';
export default function Example() {
  const [result, setResult] = useState('No decision yet');
  return (
    <Stack direction="vertical">
      <Popconfirm
        title="Archive this item?"
        description="This is a local demonstration."
        onConfirm={() => setResult('Archived')}
        onCancel={() => setResult('Kept')}
      >
        <Button>Archive</Button>
      </Popconfirm>
      <output aria-live="polite">{result}</output>
    </Stack>
  );
}
```

### Conditional availability
disabled prevents opening; a separate switch demonstrates availability.
```tsx preview
import { useState } from 'react';
import { Popconfirm, Button, Switch, Stack } from '@rockshin/tao-ui';
export default function Example() {
  const [enabled, setEnabled] = useState(false);
  return (
    <Stack direction="vertical">
      <Switch
        aria-label="Allow archive"
        checked={enabled}
        onChange={setEnabled}
      />
      <Popconfirm title="Archive item?" disabled={!enabled}>
        <Button disabled={!enabled}>Archive item</Button>
      </Popconfirm>
    </Stack>
  );
}
```

### Placement and icon
placement sets the preferred direction, and icon=null hides the default warning icon.
```tsx preview
import { Popconfirm, Button } from '@rockshin/tao-ui';
export default function Example() {
  return (
    <Popconfirm
      title="Apply changes?"
      placement="bottomRight"
      icon={null}
      okText="Apply"
      cancelText="Keep editing"
    >
      <Button>Apply changes</Button>
    </Popconfirm>
  );
}
```

## API


### [#](#popconfirm)Popconfirm



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| title | Main question text of the confirm popup (required, antd parity). | `ReactNode` **(Required)** | `-` |
| description | Secondary text shown under the title. | `ReactNode` | `-` |
| onConfirm | Called when OK is clicked; the popup also closes. | `((e?: MouseEvent<HTMLElement, MouseEvent> | undefined) => void) | undefined` | `-` |
| onCancel | Called when Cancel is clicked; the popup also closes. | `((e?: MouseEvent<HTMLElement, MouseEvent> | undefined) => void) | undefined` | `-` |
| okText | Text of the OK button. Defaults to `'OK'`. | `ReactNode` | `-` |
| cancelText | Text of the Cancel button. Defaults to `'Cancel'`. | `ReactNode` | `-` |
| okButtonProps | Extra props forwarded to the OK button. | `ButtonProps | undefined` | `-` |
| cancelButtonProps | Extra props forwarded to the Cancel button. | `ButtonProps | undefined` | `-` |
| icon | Icon shown before the title. Defaults to a warning triangle; pass `null` to hide it. | `ReactNode` | `-` |
| disabled | When true, the trigger still renders but the popup never opens. | `boolean | undefined` | `-` |
| placement | Popup side relative to the trigger. Defaults to `'top'`. | `PopoverPlacement | undefined` | `top` |
| className | Merged onto the confirm content wrapper. | `string | undefined` | `-` |
| style | Additional style | `CSSProperties | undefined` | `-` |
| children | Exactly one trigger element. | `ReactNode` **(Required)** | `-` |

