Skip to content
Browse docs and components

Confirm Button

confirm-button

A destructive button that grows into its own confirmation on a spring, so the question appears where you are looking. Focus lands on Cancel, Esc or clicking away disarms it, and the confirm button shows a spinner while the action runs.

Responsive

Install

$npxshadcnadd@forme/confirm-button

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { ConfirmButton } from "@/components/forme/confirm-button/confirm-button";

<ConfirmButton question="Delete forme-web?" onConfirm={() => deleteProject(id)}>
  Delete
</ConfirmButton>

When to use

Reach for it

  • Everyday destructive actions — removing a row, revoking a token — where a dialog would cost a context switch.
  • Rows and toolbars, where the question should appear exactly where the click was.

Use something else

  • Anything irreversible at scale, like deleting an account: use a dialog that asks the person to type the name.
  • Actions that are safe to undo. Do them at once and offer Undo in a toast instead of asking first.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

ConfirmButton

A destructive action that asks once, in place.

PropTypeDefaultDescription
children*ReactNode—The action, e.g. "Delete project".
onConfirm*() => void | Promise<void>—
questionReactNode"Are you sure?"The question shown once armed, e.g. "Delete forme-web?"
confirmLabelReactNode—The confirming button's label. Defaults to the action's own label.
iconReactNode—
disabledboolean—
classNamestring—

Accessibility

  • Focus moves to Cancel when it arms, so a second Enter never confirms by accident.
  • Escape, or moving focus out of the group, disarms it without running anything.
  • While onConfirm runs the confirm button is aria-busy and keeps its width, so focus and layout stay put.

Motion

  • The button grows into the question in 150ms and shrinks back the same way; reduced motion makes both a cut.