Message Actions

Free

The row of actions under a chat message — copy that confirms only once the clipboard write lands, thumbs up / down and regenerate — with a slot for a timestamp or token count.

</>sv-message-actions aichatcopyfeedback
import { SvMessageActionsComponent } from '@styloviz/ai/message-actions';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

With meta and regenerate

example.htmlAngular
<sv-message-actions [text]="reply.content" [actions]="['copy', 'like', 'dislike', 'regenerate']"
                    [(feedback)]="reply.feedback" (regenerate)="retry()" (copyFailed)="offerDownload()">
  <span class="text-[10px] text-gray-500">2m ago · 214 tokens</span>
</sv-message-actions>

When to use

  • Under every finished assistant reply in a chat or an answer panel.
  • Anywhere a block of generated text needs a reliable copy button and a quality signal.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
textstring''The text the copy action writes to the clipboard.
actionsreadonly SvMessageAction[]['copy', 'like', 'dislike']Which built-in actions to show, in this order.
feedbackSvMessageFeedback (two-way)nullThe reader's verdict. Two-way: the thumbs are mutually exclusive, and pressing the active one again clears it.
copyResetMsnumber2000How long the "Copied" confirmation stays, in milliseconds.
ariaLabelstring | nullnullThe group's accessible name; `null` uses the `messageActions` label.
labelsPartial<SvAiLabels>{}Per-instance text, merged over the registry's `ai` labels.

Outputs

EventPayload typeDescription
copiedstringThe text reached the clipboard. The payload is that text.
copyFailedvoidThe clipboard refused. The button shows its failed state and the hint names the shortcut; offer the text another way if you can.
regeneratevoidThe user asked for another answer.
feedbackChangeSvMessageFeedbackEmits the new `feedback` whenever it changes — the output half of `[(feedback)]`.

Customization & theming

  • `[actions]` picks the built-ins and their order: `copy`, `like`, `dislike`, `regenerate`.
  • Copy has three states: idle, copied (after the write resolves, for `copyResetMs`) and failed, which shows a hint naming the platform’s copy shortcut and emits `copyFailed`. `copy()` is public and resolves `true` only when the text actually reached the clipboard.
  • `[(feedback)]` is `'up' | 'down' | null`; the thumbs are mutually exclusive and a second press clears.
  • Text comes from the `ai` labels, or per instance through `[labels]` — `sv-ai-chat` passes its own copy-failure wording that way, because it also selects the message for the reader.
  • Free tier: uses only free icons.

Best practices

  • Do: Persist `feedback` — bind it two-way and save it with the message, so a thumbs-down survives a reload and reaches your evaluation set.
  • Do: Handle `copyFailed`. The clipboard is missing over plain HTTP and rejects when permission is denied; offer the text another way.
  • Don't: Do not show copy where your privacy policy masks the message. Leave `copy` out of `[actions]` instead of hiding it with CSS.
  • Tip: Project a timestamp or a token count into the row — it renders before the buttons.

Accessibility

  • A named group of real buttons; each thumb reports `aria-pressed`.
  • The copy button’s accessible name changes with its state, and the failure hint is a polite status message.
  • Buttons are 24×24 with visible focus rings.

Feedback on Message Actions

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.