HoldButton

Press and hold to confirm. Release early and the fill drains back. Buttons.

Open playground

About

HoldButton 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 { HoldButton } from "@ashutoshswamy/smoui" and set children, doneLabel, holdMs among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<HoldButton onComplete={() => publish()} doneLabel="Published" className="rounded-full bg-black px-6 py-3 text-white">
  Hold to publish
</HoldButton>

Props 4

children

Idle label.

ReactNode
doneLabel

Label after completing.

ReactNodedefault "Done"
holdMs

Milliseconds to hold.

numberdefault 900
onComplete

Called when the hold finishes.

() => void