SlideToConfirm
Drag across to confirm. Ink follows the thumb, floods on release and turns green when the work is done. Buttons.
Open playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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.
numbernulldefault2600- disabled
Blocks input. Enter or Space also confirms.
booleandefaultfalse
More buttons components
- AddButtonAdd + that opens into a stepper in place. The plus never moves, so a second tap lands where the first did. At one the minus becomes a bin; hold to repeat.
- AddToBagOne pill that is the add button until pressed, then grows a stepper in place. Step back to zero and it folds up again.
- ArrowButtonOn hover the arrow exits right as a second one enters from the left, and the chip swells.
- CopyButtonCopies text, then swaps its label for a drawn checkmark.
- CopyCommandA command line with a Copy button. The icon turns to a check, the word rolls to Copied and the button grows to fit.
- FillButtonThe fill floods in from the edge your pointer entered and drains out through the edge it left by.