Two-Step Button

Two-Step Button is a copy-paste React component that stops one click deleted without confirmation before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/two-step-button
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsOne click deleted without confirmation

Was this component page useful?

How do I install Two-Step Button?

pnpm dlx shadcn@latest add @bollard/two-step-button

The files land in your project. They're yours to edit.

How do I use Two-Step Button in React?

two-step-button-usage.tsx
import { TwoStepButton } from "@/components/ui/two-step-button"

<TwoStepButton
  armedLabel="Click again to delete"
  pendingLabel="Deleting…"
  confirmedLabel="Deleted"
  onConfirm={() =>
    new Promise<void>((resolve) =>
      setTimeout(() => {
        setLog("Project deleted.")
        resolve()
      }, 900),
    )
  }
>
  <Trash2 aria-hidden className="size-4" /> Delete project
</TwoStepButton>

What input mistakes does Two-Step Button catch?

  • A single accidental click (only arms)
  • Double-clicks faster than guard ms
  • Held Enter (auto-repeat)
  • Losing focus, Escape or timeout, which disarm

What props does Two-Step Button accept?

TwoStepButton props
PropTypeDefault
onConfirm* (required)

Runs on the confirming click. Return a promise to show a pending state until it settles.

() => void | Promise<void>—
timeout

How long the button stays armed, in milliseconds.

number3000
guard

Second clicks sooner than this (ms) are ignored as an accidental double-click.

number300
variant

Visual intent of the idle button. The armed state is always destructive.

keyof typeof variants"destructive"
size

Size of the button.

keyof typeof sizes"default"
armedLabel

Label while armed.

React.ReactNode"Click again to confirm"
armedHint

Read to screen readers when the button arms.

string"Press again to confirm, or Escape to cancel."
pendingLabel

Label while an async `onConfirm` is running.

React.ReactNode"Working…"
confirmedLabel

Label shown for a moment after the action is confirmed.

React.ReactNode"Done"
resetAfter

Milliseconds before the button resets after confirming. 0 keeps it confirmed.

number1600

* required. Also accepts the native props of <button> (className, aria-*, data-*…), passed through to it.

How is Two-Step Button accessible?

  • Arming is announced via a polite live region (armedHint)
  • Escape disarms; held Enter is ignored
  • aria-busy while an async confirm is pending
  • Label changes are text, not colour alone

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • A deliberate second click still confirms; it is not a full review step
  • UI guard only, not authorization

What expensive mistakes does Two-Step Button stop?

One click deleted without confirmation

Also known as

confirm button · click twice · arm button · inline confirm · delete button · are you sure · destructive button

What dependencies does Two-Step Button require?

Two-Step Button facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameTwo-Step Button
Registry identifier@bollard/two-step-button
Install commandnpx shadcn@latest add @bollard/two-step-button
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Two-Step Button

How does Two-Step Button protect destructive mutations?

Two-Step Button prevents one click deleted without confirmation. Enforces deliberate friction against A single accidental click (only arms), Double-clicks faster than guard ms, Held Enter (auto-repeat), Losing focus, Escape or timeout, which disarm. Limitation: authorize two-step-button mutations on the server.

How do I install two-step-button with shadcn?

Run `npx shadcn@latest add @bollard/two-step-button`. Sources added: registry/default/two-step-button/two-step-button.tsx. Package requirements: lucide-react.

What props customize Two-Step Button?

Two-Step Button accepts `onConfirm`, `timeout`, `guard`, `variant`, `size`. Configures confirm button, click twice, arm button behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of two-step-button?

A deliberate second click still confirms; it is not a full review step. UI guard only, not authorization Server requirement: backend verification for two-step-button.

How does Two-Step Button meet accessibility guidelines?

Arming is announced via a polite live region (armedHint). Escape disarms; held Enter is ignored. aria-busy while an async confirm is pending. Label changes are text, not colour alone. Minimizes errors: double click deleted twice, delete button no confirm.

Which components pair with Two-Step Button?