A button for an action you cannot take back: it only fires after a full press and hold. The fill sweeps with the clock, letting go early draws it back, and a finished hold runs the action and lands on a done state with a check.
Examples
Installation
npx knowns-ui@latest add hold-buttonPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Hold button from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/hold-button
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add hold-button
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/hold-button/hold-button.tsx
- components/ui/knowns/hold-button/hold-button-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/hold-button, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "hold-button" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- children
ReactNode- The label, e.g. Hold to refund $240.00.
- onCompleterequired
() => unknown- Runs after a full hold; the button is busy while a promise runs. Return false or throw to go back to the start.
- duration
number- Default
1200 - How long to hold, ms.
- doneLabel / busyLabel
ReactNode- The label once done (with a check), and while running (with a spinner). Without doneLabel it returns to the start after the action.
- tone / size
"danger"|"primary" / "sm"|"md"- Default
"danger" / "md" - Red for destructive actions, the accent otherwise; 32 or 36px high.
- hint / describedBy
boolean / string- Default
true / - - The hint under the button (Press and hold for 1.2 seconds...) that the button points aria-describedby at, or the id of your own.
- Keyboard
-- Hold Space or Enter. Letting go, moving focus away or a cancelled pointer draws the fill back.
- Motion
-- The fill follows the clock (linear); an early release draws it back in 180ms (ease out); done, the check pops (the motion lib's confirm). Reduced motion: the fill still shows progress, the rest is instant.
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | - | The label, e.g. Hold to refund $240.00. |
| onCompleterequired | () => unknown | required | Runs after a full hold; the button is busy while a promise runs. Return false or throw to go back to the start. |
| duration | number | 1200 | How long to hold, ms. |
| doneLabel / busyLabel | ReactNode | - | The label once done (with a check), and while running (with a spinner). Without doneLabel it returns to the start after the action. |
| tone / size | "danger" | "primary" / "sm" | "md" | "danger" / "md" | Red for destructive actions, the accent otherwise; 32 or 36px high. |
| hint / describedBy | boolean / string | true / - | The hint under the button (Press and hold for 1.2 seconds...) that the button points aria-describedby at, or the id of your own. |
| Keyboard | - | - | Hold Space or Enter. Letting go, moving focus away or a cancelled pointer draws the fill back. |
| Motion | - | - | The fill follows the clock (linear); an early release draws it back in 180ms (ease out); done, the check pops (the motion lib's confirm). Reduced motion: the fill still shows progress, the rest is instant. |
When to use
When to use
- An agent action a person must confirm and cannot take back: a refund, a revoke, a deploy, a bulk delete.
- A confirm that has to live in a row or a card, where a dialog would be too much.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Hold Button to my app and wire it to my own data.
- I need an agent action a person must confirm and cannot take back: a refund, a revoke, a deploy, a bulk delete. Set that up with the Knowns UI Hold Button.
- Which Hold Button props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "hold-button" }) and search_docs({ query: "hold button" }).