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

components/answer-actions.tsx
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.

TypeNotes
textstring NoWhat Copy puts on the clipboard. Leave it out to hide Copy.
onCopy(text: string) => void NoCalled after the text is copied.
onRegenerate() => void NoLeave it out to hide Regenerate.
regeneratingboolean NoKeeps the arrow turning and the button busy.
feedbackMessageFeedback No–
defaultFeedbackMessageFeedback No–
onFeedbackChange(value: MessageFeedback) => void NoLeave it out, with no `feedback`, to hide the thumbs.
reasonsstring[] NoAsked after a thumbs down. Pass an empty array to skip the question.
onReason(reason: string) => void No–
versionMessageVersion NoAdds the pager between regenerated answers.
childrenReact.ReactNode NoExtra buttons, placed after the built-in ones.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebuttontooltip

States

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