Skip to content
Haze UI

Slide to Confirm

A track with a thumb that is dragged to the end to confirm a consequential action. Falls back to a standard button without scripts.

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

When to use

  • A single action such as sending a payment is easy to trigger by mistake and a dialog would be heavy.
  • Dragging to the end suits the surrounding touch flow.

When not to use

  • The action needs its consequences explained or more input; use alert-dialog.
  • Most people will use a keyboard or assistive technology; use hold-to-confirm or a two-step button.

Installation

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

pnpm dlx shadcn@latest add @haze/slide-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 wrapper.
labelstringSend paymentAccessible name of the slider and label of the standard button.
slideLabelstringSlide to confirmText on the track before confirming.
confirmedLabelstringPayment sentText and live announcement after confirmation.
formstring–ID of a form to submit on confirmation.
namestring–Native submit button name.
valuestring–Native submit button value.
disabledbooleanfalseDims the track and blocks dragging and keys.
classstring–Classes on the wrapper.

Keyboard interactions

Arrow RightArrow UpEnterSpace
Advance the thumb by 25%. Four steps confirm.
Arrow LeftArrow Down
Move back by 25%.
HomeEscape
Return to the start.
End
Confirm at once.

Accessibility

  • The thumb is a slider with aria-valuenow (0 to 100) and a spoken value (the slide label at 0, n percent with release to cancel in between, the confirmed label when done) and a hidden description of the keys. Releasing at 90% or more confirms; a shorter drag returns the thumb to the start.
  • Confirming emits a bubbling slide-confirm event and clicks the standard button, so a form is submitted. Without scripts the standard button is shown instead of the track.
  • After confirming the thumb shows a check, stays focusable with aria-disabled, and the confirmed label is announced. The root element has a reset() method to retry. The settle and return animations are skipped under reduced motion. The layout is left-to-right.

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 "Slide to Confirm" with `npx shadcn@latest add @haze/slide-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 SlideToConfirm from "@/components/haze/ui/slide-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/slide-to-confirm.md

  • Customize with real content

    Adapt the Haze slide-to-confirm ui for our product. Replace the demo values of these props with our real content: id, label, slideLabel, confirmedLabel, form, name, value, disabled, class. Keep the layout, the heading level rules and these accessibility details: The thumb is a slider with aria-valuenow (0 to 100) and a spoken value (the slide label at 0, n percent with release to cancel in between, the confirmed label when done) and a hidden description of the keys. Releasing at 90% or more confirms; a shorter drag returns the thumb to the start. Confirming emits a bubbling slide-confirm event and clicks the standard button, so a form is submitted. Without scripts the standard button is shown instead of the track. After confirming the thumb shows a check, stays focusable with aria-disabled, and the confirmed label is announced. The root element has a reset() method to retry. The settle and return animations are skipped under reduced motion. The layout is left-to-right. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using slide-to-confirm, check it fits: use it when a single action such as sending a payment is easy to trigger by mistake and a dialog would be heavy.; dragging to the end suits the surrounding touch flow.. Avoid it when the action needs its consequences explained or more input; use alert-dialog.; most people will use a keyboard or assistive technology; use hold-to-confirm or a two-step button.. Alternatives: @haze/hold-to-confirm, @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