Message Actions
FreeThe 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 demoMore examples
With meta and regenerate
example.htmlAngular
4 lines
<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
| Name | Type | Default | Description |
|---|---|---|---|
| text | string | '' | The text the copy action writes to the clipboard. |
| actions | readonly SvMessageAction[] | ['copy', 'like', 'dislike'] | Which built-in actions to show, in this order. |
| feedback | SvMessageFeedback (two-way) | null | The reader's verdict. Two-way: the thumbs are mutually exclusive, and pressing the active one again clears it. |
| copyResetMs | number | 2000 | How long the "Copied" confirmation stays, in milliseconds. |
| ariaLabel | string | null | null | The group's accessible name; `null` uses the `messageActions` label. |
| labels | Partial<SvAiLabels> | {} | Per-instance text, merged over the registry's `ai` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| copied | string | The text reached the clipboard. The payload is that text. |
| copyFailed | void | The clipboard refused. The button shows its failed state and the hint names the shortcut; offer the text another way if you can. |
| regenerate | void | The user asked for another answer. |
| feedbackChange | SvMessageFeedback | Emits 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.