Confirm popover
A question that opens at the button that asked for it: Delete this row? with Cancel and a confirm button. It keeps the eye where the action is and puts no veil over the page. For an action that deserves the whole screen, use an alert dialog.
Install
npx shadcn@latest add @thrum-pro/confirm-popoverThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactElement | Required | The trigger: one button element. A press on it opens the question instead of running the action. |
title | ReactNode | Required | The question, in a few words. It names the panel for screen readers. |
description | ReactNode | – | One more line under the question, such as what cannot be undone. |
confirmLabel | string | Default "Confirm" | The words on the button that goes ahead. Use the verb of the action. |
cancelLabel | string | Default "Cancel" | The words on the button that backs out. |
destructive | boolean | Default false | Draw the confirm button in the destructive colour. |
onConfirm | () => void | Promise<unknown> | – | Runs when the confirm button is pressed. With a promise, the button shows a spinner and the question cannot be closed until it settles; if it rejects, the question stays open. |
onCancel | () => void | – | Runs when the question is closed any other way: Cancel, Escape or a press outside. |
open | boolean | – | Whether it is open, when the parent holds the state. Use it with onOpenChange. |
defaultOpen | boolean | Default false | Whether it starts open, when it holds its own state. |
onOpenChange | (open: boolean) => void | – | Called when the question opens or closes, whatever caused it. |
side | "top" | "right" | "bottom" | "left" | Default "top" | The side of the trigger the question opens on. It flips when there is no room. |
align | "start" | "center" | "end" | Default "center" | How the question lines up with the trigger along that side. |
sound | boolean | Default true | Play a soft sound on opening and on closing, if the visitor has sound on. |
className | string | – | Extra classes for the panel. The default is 256 pixels wide. |
Motion and sound
Motion
- The panel fades in and grows from 96% to full size over 150 ms, from the arrow that points at the trigger.
- Closing plays the same change backwards.
- While a promise from onConfirm is pending, the confirm button keeps its width and shows the button's spinner.
- Reduced motion: the panel appears and leaves at once, and the spinner stands still.
Sound
- A soft rising tone when the question opens.
- A soft falling tone when it closes, by either answer. Confirming adds no sound of its own.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The panel has role alertdialog, is named by its title and described by its description.
- Focus starts on Cancel, the answer that changes nothing, and is kept between the two buttons until the question is answered.
- While it is open the rest of the page cannot be reached by keyboard or screen reader and does not scroll. There is no veil.
- Escape and a press outside both cancel. Focus goes back to the trigger either way.
- While the action runs the confirm button says it is busy (aria-busy), keeps the focus and ignores further presses. Escape and a press outside do nothing until it settles.
- The destructive button differs from Cancel by its filled colour and by its words. Write the action as a verb.
- Under a glass material the panel and its arrow are translucent. The tint keeps the text at 4.5 to 1 over any page.
| Keys | Action |
|---|---|
| Enter / Space | On the trigger: open the question. Focus moves to Cancel. |
| Tab / Shift Tab | Move between Cancel and the confirm button. Focus stays inside the panel. |
| Enter / Space | Press the focused button. |
| Esc | Cancel: close the question without running the action. Focus returns to the trigger. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/confirm-popover.tsx- Packages
@base-ui/react@1.9.0- Brings along
- Sound engineButtonPopover
Changelog
- 1.0.0 · 2026-12-03First release.