Confirm button

Free

Destructive actions that a slip cannot trigger: hold until the fill crosses, or press twice while the button is armed. The plain Destructive and quiet Revoke styles sit beside them.

npx shadcn@latest add @pixilui/confirm-button

Preview

Hold to delete fills the button and drains if you let go early.
Show

When to use

Use it when

  • Deleting, revoking or removing something that cannot come back, in place, without a dialog.
  • A row of risky actions (remove a member, revoke a key) where a dialog per row would be heavy.

Use something else when

  • Approving an agent's action with evidence: that is the coming hold-to-approve element.
  • A destructive action that needs a typed confirmation or explains its consequences: use a dialog.
  • Anything reversible: use a plain button and offer undo.

Installation

Terminal
npx shadcn@latest add @pixilui/confirm-button

Adds confirm-button.tsx with button.tsx, and installs clsx and tailwind-merge. First PixilUI item in this app? Add the registry once, as in Installation.

Usage

example.tsx
import { ConfirmButton } from "@/components/pixilui/confirm-button";

<ConfirmButton onConfirm={onConfirm} label={label} />

Never wider than its container. Pointer, touch and keyboard all hold the same way.

API reference

PropTypeDefault
onConfirmRequired() => void | Promise<void>–Runs once the person confirms.
labelRequiredstring–The label at rest: say what happens ("Hold to remove", "Delete branch").
sizeButtonSize–Height, as on Button: xs 24, sm 28, md 32 (default), lg 36, xl 44.
mode"hold" | "two-step""hold"hold (the default) confirms after a 1200ms hold; two-step confirms on a second press while armed.
confirmLabelstring"Confirm"Two-step only: the label while armed.
doneLabelstring"Done"The label once confirmed, beside the drawn check in two-step.
variantButtonVariant–Visual weight. hold defaults to danger; two-step rests on danger-quiet and arms as danger.

Keyboard

TabMoves focus to the button.
Space EnterHold mode: holding either key fills the button; letting go early resets it.
EnterTwo-step mode: the first press arms it, a second press inside the window confirms.

Accessibility

  • A native button. The label says what happens (Hold to remove, Confirm delete, Deleted), so the state is read aloud.
  • The fill and the drain are aria-hidden; the label carries the meaning.
  • Danger text keeps 4.5:1 in light and dark on both the danger and the danger-quiet look.
  • data-status is idle, armed or done.

Motion

  • Hold: the fill sweeps across in 1200ms, linear, and lets go in 200ms when released early.
  • Two-step: the button turns danger and a darker fill drains across the arm window (3000ms); when it runs out, the button returns to rest.
  • Done: the label cross-fades to the done label, with a check that draws itself in two-step.
  • Reduced motion: no sweep or drain; the states change at once.

PixilUI Pro opens Thu 10 Dec. The first 20 licenses are $99.