HoldButton

Get this button for GPUI

A hold-to-confirm button whose inner fill grows from 0 to 100%; release early to shake and abort, hold to the end to fire the action.

Preview

Props

Variants

Fast hold

A snappier 800ms hold for low-stakes confirmations.

Slow hold

A longer 2.5s hold for high-stakes, irreversible actions.

Install

npx shadcn@latest add @evilbuttons/hold-button

Usage

import { HoldButton } from "@/components/evil-buttons/hold-button";

export function ButtonDemo() {
  return (
    <HoldButton
      duration={1500}
      label="Hold to delete"
      successLabel="Deleted"
      onConfirm={() => deleteAccount()}
      onAbort={(progress) => console.log("aborted at", progress)}
    />
  );
}

Props

The component spreads any <button> HTML attributes except onClick and onAbort.

PropTypeDefaultDescription
durationnumber1500Milliseconds the user must hold before onConfirm fires.
labelReact.ReactNode"Hold to delete"Label shown in the idle state.
holdingLabelReact.ReactNode"Keep holding…"Label shown while the button is being held.
successLabelReact.ReactNode"Deleted"Label shown after the hold completes.
onConfirm() => void-Fired once the fill reaches 100%.
onAbort(progress: number) => void-Fired when released early, with the progress (0-1) reached.
resetAfternumber1400Milliseconds to stay in the success state before resetting to idle. Set to 0 to stay.
classNamestring-Extra classes passed to the button.

Good to know

  • Release outside the button and it still aborts.
  • Hold Space or Enter to confirm from the keyboard.

Search docs

Jump to a button documentation page