Skip to content
Haze UI

Hold to Confirm

Fills as a confirmation is held, then changes to a check. Includes a standard two-step button.

pnpm dlx shadcn@latest add @haze/hold-to-confirm
Open preview in a new tab
Livesmall script

When to use

  • A consequential action is easy to trigger by mistake.
  • The effect of revoking access is already explained in the surrounding UI.

When not to use

  • A dialog is needed to explain the consequences or ask for more information.

Installation

Add the Haze registry to components.json once, then install Hold to Confirm with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/hold-to-confirm
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique ID for the control and its keyboard instructions.
labelstringRevoke linkLabel on the standard confirmation button.
holdLabelstringHold to revoke linkLabel on the press-and-hold button. Provide a translation with label.
confirmedLabelstringLink revokedText and live announcement after confirmation.
alternateLabelstring–Label for the standard two-step confirmation disclosure.
hintstringPress and hold for 1.2 sVisible hint under the button. The default states the hold time.
holdingHintstringKeep holding…Hint shown while a hold is in progress.
durationnumber1200Hold time in milliseconds, with a 500 ms minimum.
formstring–ID of a form to submit. Otherwise, listen for the click on the element marked data-hold-action.
namestring–Native submit button name.
valuestring–Native submit button value.
classstring–Classes on the wrapper.

Keyboard interactions

Hold EnterSpace
Confirm after the indicated hold time.
Escape
Cancel an active hold.

Accessibility

  • Confirmation requires one uninterrupted hold. The disclosure lets people confirm with a standard button, including when scripts are disabled.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Hold to Confirm" with `npx shadcn@latest add @haze/hold-to-confirm`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import HoldToConfirm from "@/components/haze/ui/hold-to-confirm.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/hold-to-confirm.md

  • Customize with real content

    Adapt the Haze hold-to-confirm ui for our product. Replace the demo values of these props with our real content: id, label, holdLabel, confirmedLabel, alternateLabel, hint, holdingHint, duration, form, name, value, class. Keep the layout, the heading level rules and these accessibility details: Confirmation requires one uninterrupted hold. The disclosure lets people confirm with a standard button, including when scripts are disabled. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using hold-to-confirm, check it fits: use it when a consequential action is easy to trigger by mistake.; the effect of revoking access is already explained in the surrounding ui.. Avoid it when a dialog is needed to explain the consequences or ask for more information.. Alternatives: @haze/alert-dialog, @haze/stateful-button.

Dependencies

  • npm: @lucide/astro
  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog