Message actions

Free

The row under an assistant's answer: copy, regenerate, good and bad feedback and more, as quiet icon buttons with tooltips, where copy draws a check and feedback fills its glyph.

npx shadcn@latest add @pixilui/message-actions

Preview

Copy draws its check, and a thumbs up fills its glyph, not a color.

When to use

Use it when

  • Under every assistant answer in a chat or an agent's report.
  • Anywhere a person rates a generated result and may ask for another.

Use something else when

  • Copying a single value such as a link or an ID: use Copy button.
  • Actions that change data (approve, send): use real labelled buttons, not icons.

Installation

Terminal
npx shadcn@latest add @pixilui/message-actions

Adds message-actions.tsx with button.tsx and tooltip.tsx, and installs clsx, tailwind-merge and @base-ui/react. First PixilUI item in this app? Add the registry once, as in Installation.

Usage

example.tsx
import { MessageActions } from "@/components/pixilui/message-actions";

<MessageActions
  icons={icons}
  copyValue={copyValue}
  onRegenerate={onRegenerate}
  onFeedbackChange={onFeedbackChange}
/>

One row of five 28px buttons with 40px hit areas on desktop and 44 on touch; fits at 375 wide.

API reference

PropTypeDefault
iconsRequiredMessageActionsIcons–The five icons: copy, regenerate, good, bad, more.
copyValueRequiredstring | (() => string | Promise<string>)–What Copy puts on the clipboard: the answer's text, or a function that returns it when pressed.
onRegenerate() => void | Promise<void>–Runs when Regenerate is pressed.
feedback"good" | "bad" | null–The chosen feedback, controlled. Pair with onFeedbackChange.
defaultFeedback"good" | "bad" | nullnullThe starting feedback when uncontrolled.
onFeedbackChange(feedback: MessageActionsFeedback) => void | Promise<void>–Runs with the new feedback; pressing the chosen one again sends null.
onMore() => void | Promise<void>–Runs when More is pressed: open your menu from here.

Also takes every native <div> attribute, and a ref.

Keyboard

TabMoves through copy, regenerate, good, bad and more; each shows its tooltip on focus.
EnterPresses the focused action.
SpaceThe same as Enter, on release.
EscCloses the open tooltip.

Accessibility

  • A group named Message actions holding five native buttons with aria-labels that match their tooltips.
  • Good and bad response are toggles with aria-pressed; pressing the chosen one again clears it.
  • data-rating on the root is good or bad while one is chosen, for styling and tests.

Motion

  • Copy swaps its icon deep to a check that draws itself, then returns after 1500ms.
  • Chosen feedback fills its glyph in 150ms; the button keeps its size.
  • Tooltips wait once, then open instantly as you move along the row.
  • Reduced motion: the icon changes at once, with no draw.

PixilUI Pro opens Thu 10 Dec. The first 20 licenses are $99.