Message actions preview

Message actions

The quiet bar under an AI message – copy turns into a check, regenerate spins and unfolds a version switcher, thumbs pop and ask why, read aloud becomes a tiny equalizer

  • Group
    Chat
  • Origin
    Copied · affectUI · source
  • License
    MIT
  • Added
    Oct 18
npx shadcn@latest add @deank/message-actions

The registry stays private. Install from the repo with a GitHub token — see the README.

Usage

import { MessageText } from "@/registry/components/message-actions/message-actions";

<MessageText version={/* … */}>Label</MessageText>

Props

NameTypeDefaultDescription
textstringThe message text – Copy writes it to the clipboard, and an uncontrolled read aloud is timed by its length
actionsMessageActionKey[]["copy", "regenerate", "feedback", "speak"]Which actions to show and in what order. feedback is the thumbs up and down
versionsnumber | string[]1All versions of the message, or just how many there are. From two on the "‹ 2 / 3 ›" switcher unfolds next to Regenerate
versionnumberControlled version, 0-based
defaultVersionnumbernewestStarting version when uncontrolled. Uncontrolled, the switcher jumps to a version as soon as it is added
onVersionChange(index: number) => voidCalled with the version picked in the switcher
onCopy(text?: string) => voidCalled after Copy, with text
onRegenerate() => voidCalled when Regenerate is pressed – add a version to versions and it shows up in the switcher
regeneratingbooleanfalseKeeps the arrow spinning and the bar lit while a new version is written
onFeedback(kind: "up" | "down" | null, reason?: string) => voidCalled with the vote right away, with null when it is taken back, and once more with "down" and a reason when the feedback row is sent. A new version starts without a vote
reasonsstring[]Not accurate, Too long, Didn't follow instructions, OtherQuick reasons in the feedback row. "Other" unfolds a small text field whose words are sent as the reason
onSpeak(playing: boolean) => voidCalled with true when Read aloud starts and false when it stops
speakingbooleanControlled playing state – tie it to your speech player. Without it the bar plays for speakDuration and stops on its own
speakDurationnumberfrom text, at least 2600How long an uncontrolled read aloud plays, in ms
quietbooleantrueFaded until the message (an ancestor with data-ui-message) or the bar is hovered or focused. Touch screens always show it fully
labelstring"Message actions"Accessible name of the bar
classNamestringExtra class on the root

When to use

- Under every assistant message in a chat – copy, try again, rate and listen without leaving the conversation - Wherever a model can answer more than once and people should be able to flip between the answers - When you collect feedback on answers and want a reason, not just a thumb

When not to use

Social reactions (reaction-bar).

Related

Thinking loader · Tool call card · Comment thread · Prompt input