Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Actions

MessageActions

Groups copy, retry, and rating controls under a response; the application regenerates responses and stores ratings.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add MessageActions
Interaction
Enhanced runtime
01

See it and copy it

Framework example

Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro

Your release preview includes the updated documentation and focused regression checks.

Checking the migration guide for renamed tokens

View MessageActions code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
astro
---
import { MessageActions, Stack, StreamMessage } from '@santi020k/lumen-astro'
---

<Stack gap="group">
  <StreamMessage label="Assistant response" status="complete" statusLabel="Response complete">
    <p>Your release preview includes the updated documentation and focused regression checks.</p>
    <MessageActions
      slot="actions"
      copyValue="Your release preview includes the updated documentation and focused regression checks."
      feedback="positive"
      messageId="release-preview"
      retry
    />
  </StreamMessage>
  <StreamMessage label="Assistant response" status="streaming" statusLabel="Writing a response">
    <p>Checking the migration guide for renamed tokens</p>
    <MessageActions slot="actions" copyValue="Checking the migration guide for renamed tokens" disabled messageId="migration-check" retry />
  </StreamMessage>
</Stack>
Edit MessageActions in browser

Framework differences

React: Pass feedback with onFeedback to control the rating, or defaultFeedback to start uncontrolled; null means no rating. Pass the actions to StreamMessage through its actions prop.

02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add MessageActions

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
messageIdstringrequiredIdentifies the message in retry and feedback details. An empty ID disables Retry and rating. Elements uses message-id.
copyValuestring-Text the Copy action writes to the clipboard. Omit it to leave Copy out. Elements uses copy-value.
retrybooleanfalseShows Retry, which requests a new response.
showFeedbackbooleantrueShows the Good response and Bad response pair. Elements uses show-feedback.
feedback"positive" | "negative"unratedThe current rating, shown as the pressed button. The root updates it unless ui:message-feedback is canceled.
feedback / defaultFeedback"positive" | "negative" | nullunratedPass feedback with onFeedback to control the rating, or defaultFeedback to start uncontrolled.
disabledbooleanfalseTurns off Retry and rating, for example while the answer streams. Copy stays available.
labelstringMessage actionsNames the action group.
copyLabel, copiedLabel, copyErrorLabel, retryLabel, positiveLabel, negativeLabelstringCopy, Copied, Could not copy, Retry, Good response, Bad responseLocalizes the accessible names. The buttons show icons and keep these labels as names. Elements uses kebab-case attributes.
onRetry / ui:message-retry{ messageId: string }-React callback or bubbling runtime event. The application regenerates the response.
onFeedback / ui:message-feedback{ messageId: string; value: "positive" | "negative" | null }-React callback or cancelable runtime event. The application stores the rating and asks any follow-up question.
childrenextra actions-Adds application actions after the built-in buttons.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Customize MessageActions

Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

cssScoped theme overrides
.product-message-actions {
  --surface: 0 0% 100%;
  --ink: 220 20% 15%;
  --line: 220 15% 82%;
}

Apply product-message-actions through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

HookValuesDefaultContract
class, classNamestring""Merges custom classes with the generated ui-* root classes.

Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
TabMove between Copy, Retry, and the two rating buttons.
Enter / SpaceCopy the message, request a retry, or press a rating. Pressing the selected rating clears it.

Runtime events

CustomEvents dispatched by the Astro UIPrimitives runtime for this component.

EventTargetDetailWhen
ui:message-retryMessageActions root ([data-ui-message-actions] or lumen-message-actions)LumenMessageRetryDetail: { messageId: string }Bubbles when Retry is pressed. It only requests a new response; the application regenerates it. React uses onRetry instead.
ui:message-feedbackMessageActions root ([data-ui-message-actions] or lumen-message-actions)LumenMessageFeedbackDetail: { messageId: string, value: "positive" | "negative" | null }Cancelable. Bubbles when a rating is pressed; null clears the earlier choice. Unless canceled, the root updates data-feedback. The application stores the rating. React uses onFeedback instead.

Web docsFull catalog