Skip to content
WunderUI

Chat Message Actions

Pro

Copy, regenerate and rate: four icon buttons under a finished assistant reply.

Playground

Installation

Chat Message Actions comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { ChatMessageActions } from "@wunderui/react"

Then use it:

tsx
import { useState } from "react"
import { ChatMessageActions } from "@wunderui/react"

export function ReplyActions({ answer }: { answer: string }) {
  const [feedback, setFeedback] = useState<"up" | "down" | undefined>()

  return (
    <ChatMessageActions
      feedback={feedback}
      onCopy={() => navigator.clipboard.writeText(answer)}
      onFeedback={(value) => setFeedback(feedback === value ? undefined : value)}
    />
  )
}

Expected result: You see four small grey icon buttons in a row: copy, regenerate, thumbs up and thumbs down. Press a thumb and it turns the link colour, and press it again to clear it.

When to use

Use Chat Message Actions for

  • The copy, regenerate and thumbs controls under a finished assistant reply
  • A rating that you send to your own feedback endpoint
  • A chat that lets people ask the assistant again for the same question

Use something else for

  • Chat Message for the bubble the actions sit under
  • Chat Loader for the dots shown while the reply is being regenerated
  • Toolbar for a row of actions that belongs to a whole page or editor, with several groups

Placement

The row is a plain flex row, so you place it. Under the bubble, indented by the avatar width, it keeps the bubble's edge clear, and under a plain reply it sits under the text.

Revenue grew 12% quarter over quarter to $1,842,000. 1,204 new customers joined and churn fell to 1.8%.

Copy status

The Copy button keeps its name and never changes. Confirm the copy in a status line next to the row, and press Copy to try the real clipboard.

Newer props

Each button shows only when its handler is set. Copy confirms with a check, a thumbs down with feedbackReasons asks what could be better, and regenerateOptions adds a Regenerate with row.

Copy confirmation, feedback reasons and regenerate options

Regenerate with:

Keyboard interactions

The four actions are native buttons in one row, so the browser handles focus and activation. There is no arrow-key navigation, and every button is a tab stop.

TaborShiftTab
Moves focus to the next or previous action in this order: Copy, Regenerate, Good response, Bad response. Focus shows as an indigo border with a 2 px ring.
EnterorSpace
Presses the focused button: copies, regenerates, or sets the rating.
EnterorSpace
On a thumb that is already pressed, the press reaches with the same value again; clear the rating there to turn it off.

Behavior and motion

What the row does with its handlers, its state, assistive technology and motion.

Handlers
Every button calls its handler and does nothing else. All handlers are optional, and a button without one still renders and takes focus.
Clipboard
The row writes nothing to the clipboard, so do it in the copy handler. The browser call rejects without permission, so catch it and say so in the status line.
Rating
The feedback value is controlled: up presses Good response, down presses Bad response, anything else presses neither. A pressed thumb takes the link colour.
Names
Each button has an aria-label (Copy, Regenerate, Good response, Bad response) and the same text as a title. Only the thumbs report a pressed state, since the other two are actions.
Live region
The row is not a live region and its names do not change after a press. Put a status line next to it that is in the page from the start, and fill it with Copied or Could not copy.
States
Hover fills the button with the page tone and darkens the icon, pressed fills it with the subtle tone, and focus is an indigo border with a 2 px ring. The icons are 14 px in a 24 px target.
Motion
None. Hover, pressed and focus change colour and ring at once, and nothing moves, so there is nothing to reduce.

Anatomy

The figure marks the row and its four buttons. The buttons are native buttons named by aria-label.

  • A flex row with 2 px between its buttons. It takes handlers for copy, regenerate and feedback, and the rating already given.

  • A 24 px icon button named Copy. It calls the copy handler and writes nothing to the clipboard itself.

  • A 24 px icon button named Regenerate that calls the regenerate handler.

  • A thumbs-up button, shown as pressed when the feedback is up. It calls the feedback handler with up.

  • A thumbs-down button, shown as pressed when the feedback is down. It calls the feedback handler with down.

Best practices

  • Do

    Show the row when the reply is complete, not while it streams. Copy and Regenerate act on the whole message.

  • Do

    Write to the clipboard in the copy handler with navigator.clipboard.writeText, and catch a refusal. It fails without permission and on pages that are not secure.

  • Do

    Confirm the copy in a status line next to the row that is in the page before it has text. The button keeps the name Copy, so without the line a screen reader user hears nothing.

  • Do

    Hold the rating in state and hand it back as feedback, so the matching thumb stays pressed, also after a reload. Clear it when the same thumb is pressed again and when the reply is regenerated.

  • Don’t

    Don't pass a feedback handler without storing the value. The thumbs only mirror the feedback value and do not toggle on their own.

  • Don’t

    Don't show the row on a user message or on a reply that failed. Offer a retry there instead.

  • Don’t

    Don't rely on the title tooltip for the meaning of the icons. Hover is not available on touch, so the aria-label is the name.

API reference

ChatMessageActions is a plain component, so this table lists every prop.

A flex row with 2 px between its buttons. It takes handlers for copy, regenerate and feedback, and the rating already given.

PropTypeDefaultDescription
onCopy() => void—Called when Copy is pressed. Write the reply to the clipboard here and confirm it; the component does neither.
onRegenerate() => void—Called when Regenerate is pressed. Start the reply again and hide the row until it is complete.
feedback"up" | "down"—The rating already given: presses Good response, presses Bad response, leaving it out presses neither.
onFeedback(value, detail?) => void—Called with or when a thumb is pressed, also when it is already pressed. Store the value and hand it back as .
classNamestring—Extra classes for the row, for example to line it up with a bubble that has an avatar, or under text.
defaultFeedbackOpenbooleanfalseOpens the reasons panel on first render, for a demo state or a screen that starts mid-feedback. Needs .
feedbackReasonsstring[]—
onRegenerateWith(option) => void—
regenerateOptionsstring[]—

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("chat-message-actions")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.