Skip to content

Action Button

One button that morphs through a run: Run, then working with a spinner, then a done check, then back. The width follows the label, the icon crossfades and the check pops; it never swaps for another element.

On this page

Examples

Installation

npx knowns-ui@latest add action-button
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

children / icon
ReactNode
The idle label and its icon, e.g. Run with a play glyph.
workingLabel / doneLabel
ReactNode
Default"Working" / "Done"
The label while it runs (with a spinner) and once it is done (with a check).
onAction
() => unknown
Runs on click. While it runs the button stays focusable, aria-busy, and ignores clicks. Return false or throw to go back to idle at once.
state / onStateChange
"idle" | "working" | "done"
Control it yourself, for a run that lives elsewhere (a queue, a server push).
doneFor
number
Default1600
How long Done shows before it eases back, ms; 0 keeps it.
variant / size
Button's
Default"primary" / "md"
The same looks and sizes as Button.
Motion
-
The label width eases to the next label (180ms, ease out), the icon crossfades (120ms), the label settles with a 4px rise, and the check pops on Done (the motion lib's confirm). Reduced motion: instant.

When to use

When to use

  • A button that starts a run and should show how it went in place: Run evals, Sync now, Deploy.
  • A toolbar or card action where a toast for every run would be noise.

When not to use

  • Actions that cannot be undone: make them hold to confirm: use Hold Button.
  • Long runs with steps to watch: use Progress.

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 Action Button to my app and wire it to my own data.
  • I need a button that starts a run and should show how it went in place: Run evals, Sync now, Deploy. Set that up with the Knowns UI Action Button.
  • Which Action Button props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "action-button" }) and search_docs({ query: "action button" }).

Need help?

Stuck on Action Button, or found something off? We read every message.