Skip to Content
Actions & Basics@hacline/ui/confirm-button

ConfirmButton

In-place morphing confirmation button for destructive actions. Smoothly expands into Confirm/Cancel or charges a 1.5s hold progress bar with full keyboard and focus management.

Import

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

Expand Mode (Default)

Clicking the trigger smoothly morphs the button in-place into [ Confirm | Cancel ] with zero gaze jump. Focus automatically moves to the Cancel button by default (initialFocus="cancel"), supports ArrowLeft / ArrowRight roving navigation, and disarms on Escape or outside press.

Ready

Hold-to-Confirm Mode

Set mode="hold" to charge an in-button progress bar over holdDuration (defaults to 1500ms). Works with mouse, touch, pen, and keyboard (Space or Enter), and cancels smoothly on early release, pointer drift, Escape, or blur.

Hold for 1.5s (mouse, touch, or Space)

Async Loading State

When onConfirm returns a Promise, the button automatically enters data-pending, sets aria-busy="true", blocks duplicate submissions and Escape dismissal until settled, and collapses back to idle on resolution. If the Promise rejects, it clears data-pending while staying armed so the user can retry or cancel.

Returns a Promise for automatic pending protection

Sizes

Adjust the button and expanded capsule height with size (sm, md, lg).

Props

Prop

Type

Keyboard Interactions

KeyBehavior
Enter / SpaceIn expand mode, arms the button and focuses initialFocus. In hold mode, hold to charge confirmation.
ArrowLeft / ArrowRightMoves focus between the Confirm and Cancel actions while armed.
EscapeDisarms expand mode and restores focus to the trigger, or cancels an active hold gesture.

Data Attributes

AttributeDescription
data-slot="confirm-button"Root container element
data-mode="expand" | "hold"Current confirmation mode
data-armedPresent while expanded in expand mode
data-holdingPresent while pressing in hold mode
data-heldPresent once holdDuration has elapsed
data-pendingPresent while an async onConfirm Promise is pending
data-disabledPresent when disabled