The quiet action bar under an assistant message: Copy, thumbs up and down with a short reason picker, Regenerate with a version switcher, and an overflow menu with Read aloud and your own actions.
Used for
- Copy a reply
- Regenerate a reply
- Rate a response
- Switch reply versions
- Read a reply aloud
Examples
Installation
npx knowns-ui@latest add message-actionsFor 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 Message actions 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/message-actions
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 message-actions
```
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
- components/ui/knowns/kbd.tsx
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/input.tsx
- components/ui/knowns/menu.tsx
- components/ui/knowns/toggle-group.tsx
- components/ui/knowns/message-actions/message-actions.tsx
- components/ui/knowns/message-actions/message-actions-utils.ts
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/message-actions, 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: "message-actions" }) 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
- text
string- The message, for Copy and Read aloud.
- onCopy
() => void- After the text is copied. The icon turns into a check for a moment.
- onRegenerate / regenerating
() => void|Promise / boolean- Shows Regenerate. The icon spins while the promise is pending, or while regenerating is true.
- version / versions / onVersionChange
number / number / (v) => void- Default
1 / 1 - From two versions on, a ‹ 2/3 › switcher appears next to Regenerate.
- feedback / onFeedback
Feedback / (value, reason?) => void- Thumbs up or down (click again to clear). Down opens a small picker; Send passes { reasons, note }.
- reasons
string[]- Default
5 defaults - Chips in the picker.
- readAloud / onReadAloud
boolean / (playing) => void- Default
true - Read aloud in the overflow menu, with the browser's speech where there is one. While reading, a Stop button with a small equalizer shows.
- more / onMore
MenuItem[] / (item) => void- Your own actions in the overflow menu.
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | - | The message, for Copy and Read aloud. |
| onCopy | () => void | - | After the text is copied. The icon turns into a check for a moment. |
| onRegenerate / regenerating | () => void | Promise / boolean | - | Shows Regenerate. The icon spins while the promise is pending, or while regenerating is true. |
| version / versions / onVersionChange | number / number / (v) => void | 1 / 1 | From two versions on, a ‹ 2/3 › switcher appears next to Regenerate. |
| feedback / onFeedback | Feedback / (value, reason?) => void | - | Thumbs up or down (click again to clear). Down opens a small picker; Send passes { reasons, note }. |
| reasons | string[] | 5 defaults | Chips in the picker. |
| readAloud / onReadAloud | boolean / (playing) => void | true | Read aloud in the overflow menu, with the browser's speech where there is one. While reading, a Stop button with a small equalizer shows. |
| more / onMore | MenuItem[] / (item) => void | - | Your own actions in the overflow menu. |
Accessibility
- A toolbar with one tab stop: Left and Right Arrow move between buttons, Home and End jump to the ends.
- Every button has a name and a tooltip; thumbs are toggle buttons (aria-pressed).
- Copied, thanks and reading states are announced in a polite live region.
- With reduced motion the pop, spin and equalizer are still.
What it handles
- 01Copies the text prop to the clipboard, turns the icon into a check for about a second and a half, and calls onCopy.
- 02Shows Regenerate when you pass onRegenerate, spins until a returned promise settles, or follows the regenerating prop.
- 03Adds a version switcher such as 2/3 once versions is above one, and calls onVersionChange as you step through.
- 04Toggles thumbs up and down with aria-pressed, and a thumbs down opens a reason picker of chips and a short note before it sends.
- 05Puts Read aloud in the overflow menu using browser speech, with a live equalizer while it plays, and appends your own items from more.
- 06Acts as one toolbar: one tab stop, with arrow keys moving between buttons, and a polite live region announces each result.
States
- First render
- Nothing. The bar paints as it is
- none
- Copy
- The icon swaps to a check, then back
- none
- Thumb pressed
- The icon pops up and settles
- 280ms, ease out
- Reason picker opens
- It slides in from slightly above
- 180ms, ease out
- Regenerating
- The icon spins until it settles
- none
- Reading aloud
- Three equalizer bars move
- none
- Reduced motion
- Pop, spin and equalizer stay still
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The bar paints as it is | none |
| Copy | The icon swaps to a check, then back | none |
| Thumb pressed | The icon pops up and settles | 280ms, ease out |
| Reason picker opens | It slides in from slightly above | 180ms, ease out |
| Regenerating | The icon spins until it settles | none |
| Reading aloud | Three equalizer bars move | none |
| Reduced motion | Pop, spin and equalizer stay still | 0ms |
Works with
When to use
When to use
- Copy, rate, regenerate and read aloud under each assistant message.
- Collecting why an answer was bad, in two clicks, without leaving the chat.
When not to use
- The input where people write: use Chat Composer.
- Whole-page actions in a header: use Page Header.
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 Message Actions to my app and wire it to my own data.
- I need copy, rate, regenerate and read aloud under each assistant message. Set that up with the Knowns UI Message Actions.
- Which Message Actions props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "message-actions" }) and search_docs({ query: "message actions" }).