SlideToConfirm

Drag across to confirm. Ink follows the thumb, floods on release and turns green when the work is done. Buttons.

Open playground

About

SlideToConfirm is a React component in the Buttons category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SlideToConfirm } from "@ashutoshswamy/smoui" and set label, onConfirm, resetAfter among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { SlideToConfirm } from "@ashutoshswamy/smoui";

<SlideToConfirm
  label="Slide to pay $48.00"
  confirmingLabel="Paying"
  doneLabel="Paid"
  onConfirm={async () => { await pay(); }}
/>

Props 4

label / confirmingLabel / doneLabel

Idle, busy and done text.

string
onConfirm

The real work. A rejection sends the thumb home.

() => Promise<unknown> | unknown
resetAfter

Rewind after done, in ms. null stays done.

numbernulldefault 2600
disabled

Blocks input. Enter or Space also confirms.

booleandefault false