Message Actions
Copy, regenerate and rate an answer, with every button confirming in place.
- Category
- AI Chat
- Access
- Free with an account
- Source
- 290 lines · one file
- States
- 6 drawn
When to use it
Use Message Actions under an assistant answer: copy, regenerate, thumbs up or down with a "what was wrong" list, and a pager between regenerated versions. Every action is a callback, so you store feedback wherever you like.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Message Actions for this.
Install it: npx shadcn@latest add @liro/message-actions
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/message-actions.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { MessageActions, type MessageFeedback } from "@/components/ui/message-actions";
export function AnswerActions({
text,
onRegenerate,
onFeedback,
}: {
text: string;
onRegenerate: () => void;
onFeedback: (feedback: MessageFeedback) => void;
}) {
return (
<MessageActions
text={text}
onRegenerate={onRegenerate}
onFeedbackChange={onFeedback}
reasons={["Not accurate", "Too long", "Didn't follow instructions"]}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
text | string | No | What Copy puts on the clipboard. Leave it out to hide Copy. |
onCopy | (text: string) => void | No | Called after the text is copied. |
onRegenerate | () => void | No | Leave it out to hide Regenerate. |
regenerating | boolean | No | Keeps the arrow turning and the button busy. |
feedback | MessageFeedback | No | – |
defaultFeedback | MessageFeedback | No | – |
onFeedbackChange | (value: MessageFeedback) => void | No | Leave it out, with no `feedback`, to hide the thumbs. |
reasons | string[] | No | Asked after a thumbs down. Pass an empty array to skip the question. |
onReason | (reason: string) => void | No | – |
version | MessageVersion | No | Adds the pager between regenerated answers. |
children | React.ReactNode | No | Extra buttons, placed after the built-in ones. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttontooltipStates
All of them are drawn by the component. None is left for you to design.
- Default
- Copied
- Regenerating
- Rated up
- Rated down
- Asking why
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances