Skip to content
English
Slide to confirm comes with Pro. Its preview shows once you unlock it.

How it works

Position comes from one CSS variable, --_p (0 to 1): a runner exactly as wide as the travel distance moves the handle with translateX, and the fill and hint text derive from the same value, so a width change never misaligns anything. Dragging uses Pointer Events with pointer capture and writes the variable directly, without React renders. The handle is a <button>, not a slider: a plain tap only nudges it to hint that sliding is needed.

Use it for

  • Irreversible actions that need protection from accidental taps: paying, withdrawing, confirming a delivery.
  • The main confirm action at the bottom of a mobile screen, instead of a button plus a confirmation dialog.
  • Steps with financial consequences, such as releasing funds.

Look elsewhere when

  • Ordinary, reversible actions: a plain button is cheaper than sliding.
  • Desktop-first admin forms: a button with a confirmation dialog is handier than dragging.
  • Several confirmations side by side: use sliding only for the one that matters most.

Usage

import { useRef } from 'react'
import { SlideToConfirm } from './SlideToConfirm.jsx'

export function PayBar({ orderId }) {
  const ref = useRef(null)
  return (
    <SlideToConfirm
      ref={ref}
      label="Slide to pay"
      loadingLabel="Paying…"
      doneLabel="Payment complete"
      threshold={0.8}
      // Return a Promise: loading shows meanwhile, and failure resets the handle
      onConfirm={() => api.pay(orderId)}
    />
  )
  // To start over: ref.current?.reset(), or give the component a new key
}

Props

PropTypeDefaultWhat it does
labelReactNode'Slide to confirm'Hint text on the track (with the shimmer), also the accessible name of the handle button.
loadingLabelReactNode'Processing…'Shown while the Promise returned by onConfirm is pending.
doneLabelReactNode'Confirmed'Shown after completion.
labelsobject—Replaces other built-in text (hint, the instruction read by screen readers). Shallow-merged over the English defaults.
thresholdnumber0.8How far across the track the handle must be released to confirm, 0 to 1.
onConfirm() => void | Promise<unknown>—Called on confirm. A returned Promise shows loading, resolves to the done state and resets the handle on rejection.
disabledbooleanfalseDisables the control.
refRef<{ reset(), focus() }>—reset() returns the handle to the start and discards a pending result; focus() focuses the handle. A new key also works.
...restHTMLAttributes<HTMLDivElement>—Other attributes, such as className and style, go to the root.

Accessibility

  • The handle is a focusable <button>: Enter, Space, Right Arrow and End confirm directly, and aria-describedby gives the instruction.
  • Screen reader activation (a click without a pointer press) also confirms; a plain pointer tap does not.
  • Processing and done states are read through an aria-live region; once done the button name changes and aria-disabled is set, so focus is not lost.
  • The knob is 50×50 and the track 60px tall; touch-action: pan-y keeps vertical page scrolling.
  • With reduced motion the shimmer is removed, snapping and returning are instant and the check is not drawn; dragging still follows 1:1.

Motion

Dragging has no transition and follows 1:1; returning below the threshold 360ms ease-out (no overshoot against the wall); snapping past it 240ms ease-out, then the knob lands with a 560ms spring bounce (1.12). Pressing shrinks the knob to 0.92 in 100ms and it springs back in 360ms. Icon switch 240ms spring; check draw 360ms after 80ms; shimmer 2.8s per sweep; tap nudge 14px over 520ms spring.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

SlideToConfirm.jsxslide-to-confirm.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Form inputs
Availability grid comes with Pro. Its preview shows once you unlock it.
Boolean operations comes with Pro. Its preview shows once you unlock it.
Cascader comes with Pro. Its preview shows once you unlock it.