Calm by default, clear about state, comfortable to press - with a loading state that keeps focus.
Used for
- Run an agent
- Confirm a delete
- Send a prompt
- Retry a failed run
- Open a model picker
Examples
Installation
npx knowns-ui@latest add buttonFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install 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/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 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
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
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/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: "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
- variant
"primary"|"secondary"|"ghost"|"destructive"|"quiet"- Default
"primary" - Solid chip, hairline chip, text only, soft red for deleting, or quiet: inline text actions like “Show more” with no chip and no lift.
- size
"xs"|"sm"|"md"|"lg"- Default
"md" - 24, 28, 32 or 36px high; taller on touch screens. xs is for dense clusters like zoom controls. Quiet buttons take only the text size.
- icon / iconRight
ReactNode- Icons before / after the label. Icon only (no children) makes it square: add an aria-label.
- loading
boolean- Default
false - Spinner replaces the left icon and a soft band sweeps the label. Stays focusable, sets aria-busy, ignores clicks.
- ...props
button attributes- Everything a native button takes, including ref, type and disabled.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "primary" | "secondary" | "ghost" | "destructive" | "quiet" | "primary" | Solid chip, hairline chip, text only, soft red for deleting, or quiet: inline text actions like “Show more” with no chip and no lift. |
| size | "xs" | "sm" | "md" | "lg" | "md" | 24, 28, 32 or 36px high; taller on touch screens. xs is for dense clusters like zoom controls. Quiet buttons take only the text size. |
| icon / iconRight | ReactNode | - | Icons before / after the label. Icon only (no children) makes it square: add an aria-label. |
| loading | boolean | false | Spinner replaces the left icon and a soft band sweeps the label. Stays focusable, sets aria-busy, ignores clicks. |
| ...props | button attributes | - | Everything a native button takes, including ref, type and disabled. |
What it handles
- 01Draws five variants (primary, secondary, ghost, destructive and quiet) in four sizes, xs to lg, from one cva map you can extend with a variant of your own.
- 02Turns into a square icon button when it has an icon and no children, so an aria-label is all an icon-only action needs.
- 03Takes the loading prop to swap the left icon for a Spinner, set aria-busy and ignore clicks while the button stays focusable.
- 04Reads the primary fill from --kn-accent, falling back to --primary, so one token recolours every primary button on the page.
- 05Grows to 32, 36 or 40px high on touch screens through pointer-coarse, so a small button is still a fair target for a thumb.
- 06Exports buttonClass and buttonVariants so a link or a router anchor can wear the button look without being wrapped in a button.
States
- First render
- Nothing. It paints as it is
- none
- Hover
- Fill and ink change colour; ghost and quiet buttons brighten their text
- 120ms, ease out
- Pressed
- Filled buttons shrink to 97% while the pointer is down; quiet buttons do not
- 120ms, ease out
- Keyboard focus
- A focus ring appears around the button
- none, at once
- Loading
- A Spinner replaces the left icon and a soft band sweeps across the label on a loop
- none
- Disabled
- The button dims to half strength and the cursor changes
- none, at once
- Reduced motion
- The press scale and the label sweep are off
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. It paints as it is | none |
| Hover | Fill and ink change colour; ghost and quiet buttons brighten their text | 120ms, ease out |
| Pressed | Filled buttons shrink to 97% while the pointer is down; quiet buttons do not | 120ms, ease out |
| Keyboard focus | A focus ring appears around the button | none, at once |
| Loading | A Spinner replaces the left icon and a soft band sweeps across the label on a loop | none |
| Disabled | The button dims to half strength and the cursor changes | none, at once |
| Reduced motion | The press scale and the label sweep are off | 0ms |
Works with
When to use
When to use
- Any action the user triggers: submit, save, run, cancel, with a loading state that stays focusable.
When not to use
- Navigation to another page: use a link.
- An on/off state: use Switch.
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 Button to my app and wire it to my own data.
- I need any action the user triggers: submit, save, run, cancel, with a loading state that stays focusable. Set that up with the Knowns UI Button.
- Which Button props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "button" }) and search_docs({ query: "button" }).