Animated React button components

Hold to confirm

Hold to fill, let go to cancel. Finish the hold and it morphs into a confirmed state. Works with Space and Enter too.

Buttons, press and hold, Motion

Install

npm i clsx lucide-react motion tailwind-merge && curl -o components/hold-to-confirm.tsx https://motion-brew.com/r/hold-to-confirm.tsx

One self contained file for React and Tailwind CSS: hold-to-confirm.tsx. Or ask your AI agent to add it through the MCP server.

Usage

import { HoldToConfirm } from "@/components/hold-to-confirm";

export default function Page() {
  return <HoldToConfirm duration={1200} onConfirm={() => deleteProject()} />;
}

Props

PropTypeDefaultDescription
childrenReactNode"Hold to delete"Label before and during the hold
iconReactNodetrash iconIcon before the label, null for none
confirmedLabelReactNode"Deleted"Label after completion
durationnumber1200Hold length, ms
resetAfternumber1600Confirmed state length, ms
onConfirm() => voidCalled once on completion
fillClassNamestringneutralFill color class (near-black, near-white in dark)

More buttons

  • Bell toggle: A pill toggle where a press rings the bell, crossfades the label and unfurls the pill.
  • Slide commit: Slide to confirm: drag the handle past the line and it commits with a spinner and a green check; let go early and it springs home.
  • Download button: A download pill whose page icon fills up like liquid as the percentage counts, while a waving fill sweeps across, then a check lands on the page.
  • Receipt button: A pay button that turns into a receipt printer: progress fill, check draw, line-by-line paper feed and a torn-off receipt.

All animated react button components