Cómo funciona
The popover is placed against the closest data-ds-boundary element or the viewport, shifting sideways with its arrow kept on the trigger and flipping when there is no room. While a returned promise is pending both buttons hold: the label lifts away for a spinner, then a check is drawn and the popover closes after 650ms.
Úsalo para
- Confirming a single, reversible-but-costly inline action such as removing a member or revoking a link.
- Places where a full dialog would feel heavy.
Busca otra opción cuando
- Irreversible actions with wide impact: use a confirm dialog that names what is lost.
- Actions that can simply be undone: act and offer Undo instead.
Uso
import { Popconfirm } from './Popconfirm.jsx'
export function RemoveMember({ member }) {
return (
<Popconfirm
title={`Remove ${member.name}?`}
description="They lose access to every project right away."
confirmLabel="Remove"
onConfirm={() => api.removeMember(member.id)}
>
<button type="button">Remove</button>
</Popconfirm>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
children | ReactElement | — | The trigger button; it gets aria-haspopup and aria-expanded. |
title | ReactNode | — | The question. |
description | ReactNode | — | The consequence, in one sentence. |
onConfirm | () => void | Promise | — | Runs on confirm. A promise shows progress; rejecting keeps the popover open with errorLabel. |
tone | 'danger' | 'default' | 'danger' | Red confirm and warning icon, or ink and a question icon. |
side | 'top' | 'bottom' | 'top' | Preferred side; flips when there is no room. |
confirmLabel / cancelLabel / errorLabel | string | 'Confirm' / 'Cancel' / 'That didn’t work. Try again.' | Button and error text. |
defaultOpen | boolean | false | Open on first render (without taking focus). |
onOpenChange | (open: boolean) => void | — | Called when it opens or closes. |
Accesibilidad
- role alertdialog labelled by the title and described by the description; the trigger carries aria-haspopup and aria-expanded.
- Opening moves focus to Cancel, so Enter never confirms by accident; Tab cycles between the two buttons.
- Escape, Cancel or a click outside closes it and returns focus to the trigger.
- The confirm button sets aria-busy while waiting; an error is announced with role alert.
- Danger is shown by an icon and wording, not colour alone.
- With reduced motion the popover fades and the spinner turns slowly.
Movimiento
Enter 200ms cubic-bezier(0.32, 1.25, 0.5, 1) from 0.94 scale at the arrow; leave 120ms; label lifts 4px, spinner and check spring in, check stroke draws in 280ms.
Añádelo a tu proyecto
Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.
Popconfirm.jsxpopconfirm.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

