Skip to contentKino
Skip to Content

Confirm button

A Button for an action that is hard to take back, confirmed in place. It grows into a question with Cancel beside the action, shows a spinner while the action runs, then says how it went, with Undo.

npx shadcn add https://kinoui.com/r/confirm-button.json
Share on

Examples

Storage

Kino workspace · 4.8 GB of 10 GB used
Trash23 files · 1.2 GB
Version historyKept for 90 days · 640 MB

Default

Give it the action as onConfirm and the way back as onUndo. It asks, shows a spinner while the action runs, then says how it went, with Undo.

LF
Lucía Fernández

The empty state needs a way back to search.

Icon only

Give an icon size an aria-label. It widens into the question, so give it a line with room to grow into, such as the name’s.

Production keykino_live_••••7f3a

Destructive

Leave out onUndo for an action with no way back: the result says it is done and goes back to rest.

KW
Kenji WatanabeEngineer

Failure

A promise that rejects shows failedLabel with Try again. This one fails the first time.

Long question

Name what goes. A question too long for one line takes its own, with Cancel and the action below it.

Sizes

Cancel and the action take the button’s size.

Installation

npx shadcn@latest add https://kinoui.com/r/confirm-button.json
Files
lib/reduce-motion.tslib/scroll.tslib/refs.tslib/resize.tslib/swap.tsxlib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/announce.tsxlib/notice.tsxlib/settle.tscomponents/kino/confirm-button.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
onConfirm() => unknownNoneRuns the action. A promise keeps the spinner until it settles; one that rejects, or a throw, shows failedLabel with Try again.
onUndo() => unknownNoneShows Undo in the result. A promise keeps Undo’s spinner until it settles; one that rejects shows undoFailedLabel.
childrenReactNodeNoneThe button at rest: its label, or an icon with an aria-label.
questionstring'Delete?'What it asks. Name what goes, such as “Delete 1,284 archived conversations?”.
confirmLabelstring'Delete'The action’s label in the question: what it does, never “OK”.
cancelLabelstring'Cancel'The way out, beside the action.
doneLabelstring'Deleted'What the result says, and a screen reader hears, once the action has worked.
failedLabelstring'Couldn’t delete'What it says when the action fails.
retryLabelstring'Try again'The button beside a failure.
undoLabelstring'Undo'The button beside the result, with onUndo.
undoneLabelstring'Restored'What a screen reader hears once Undo has worked.
undoFailedLabelstring'Couldn’t undo'What the result says when Undo fails; Undo stays, to try again.
timeoutnumber5000How long the result shows, in ms, before the button goes back to rest. It waits while the result is hovered or has keyboard focus; Infinity keeps it.

Data attributes

AttributeOnDescription
data-statusConfirmButtonrest, asking, working, done or failed: where the button is.

CSS variables

VariableSet it onDefaultDescription
--swap-scaleConfirmButton, or <body>0.97How far the view that leaves shrinks as it fades, and the one that arrives grows from.
--swap-blurConfirmButton, or <body>2pxHow far the views blur as they swap.

Accessibility

  • The question is a group named by its words, and focus moves to Cancel when it opens, so Enter twice never acts.
  • Escape, a press elsewhere and Tab away cancel the question; Escape and Cancel put focus back on the button.
  • The second press of a double click and a held key’s repeats never answer the question.
  • A polite status region says how the action went, and that Undo worked or failed.
  • Focus moves to Undo, or to the result, when the action ends, and back to the button when the result goes; a disabled button stays focusable, so focus never falls to the page.
  • A failure shows an alert icon and words, not a colour alone.