Your release preview includes the updated documentation and focused regression checks.
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
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.
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.---
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>'use client'
import { useState } from 'react'
import { MessageActions, Stack, StreamMessage } from '@santi020k/lumen-react'
const answer = 'Your release preview includes the updated documentation and focused regression checks.'
const draft = 'Checking the migration guide for renamed tokens'
export function Example() {
const [feedback, setFeedback] = useState<'positive' | 'negative' | null>('positive')
const [statusLabel, setStatusLabel] = useState('Response complete')
return (
<Stack gap="group">
<StreamMessage
actions={
<MessageActions
copyValue={answer}
feedback={feedback}
messageId="release-preview"
onFeedback={({ value }) => {
// Store the rating in your application, then show it.
setFeedback(value)
}}
onRetry={() => {
// Ask your application to regenerate the response.
setStatusLabel('Retry requested')
}}
retry
/>
}
label="Assistant response"
status="complete"
statusLabel={statusLabel}
>
<p>{answer}</p>
</StreamMessage>
<StreamMessage
actions={<MessageActions copyValue={draft} disabled messageId="migration-check" retry />}
label="Assistant response"
status="streaming"
statusLabel="Writing a response"
>
<p>{draft}</p>
</StreamMessage>
</Stack>
)
}<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-stack gap="group">
<lumen-stream-message label="Assistant response" status="complete" status-label="Response complete">
<p>Your release preview includes the updated documentation and focused regression checks.</p>
<lumen-message-actions
slot="actions"
copy-value="Your release preview includes the updated documentation and focused regression checks."
feedback="positive"
message-id="release-preview"
retry></lumen-message-actions>
</lumen-stream-message>
<lumen-stream-message label="Assistant response" status="streaming" status-label="Writing a response">
<p>Checking the migration guide for renamed tokens</p>
<lumen-message-actions slot="actions" copy-value="Checking the migration guide for renamed tokens" disabled message-id="migration-check" retry></lumen-message-actions>
</lumen-stream-message>
</lumen-stack>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
let mut rating = use_signal(|| None::<MessageFeedback>);
rsx! {
MessageActions {
copy_value: "The quarterly total is 4,200.",
feedback: Some(rating()),
message_id: "m1",
on_feedback: move |detail: MessageFeedbackDetail| rating.set(detail.value),
on_retry: move |_: MessageRetryDetail| {},
retry: true,
}
}
}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.
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.
pnpm add @santi020k/lumen-astrolumen add MessageActionspnpm add @santi020k/lumen-reactlumen add MessageActions --target reactpnpm add @santi020k/lumen-elementslumen add MessageActions --target elementsAPI 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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| messageId | string | required | Identifies the message in retry and feedback details. An empty ID disables Retry and rating. Elements uses message-id. |
| copyValue | string | - | Text the Copy action writes to the clipboard. Omit it to leave Copy out. Elements uses copy-value. |
| retry | boolean | false | Shows Retry, which requests a new response. |
| showFeedback | boolean | true | Shows the Good response and Bad response pair. Elements uses show-feedback. |
| feedback | "positive" | "negative" | unrated | The current rating, shown as the pressed button. The root updates it unless ui:message-feedback is canceled. |
| feedback / defaultFeedback | "positive" | "negative" | null | unrated | Pass feedback with onFeedback to control the rating, or defaultFeedback to start uncontrolled. |
| disabled | boolean | false | Turns off Retry and rating, for example while the answer streams. Copy stays available. |
| label | string | Message actions | Names the action group. |
| copyLabel, copiedLabel, copyErrorLabel, retryLabel, positiveLabel, negativeLabel | string | Copy, Copied, Could not copy, Retry, Good response, Bad response | Localizes 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. |
| children | extra actions | - | Adds application actions after the built-in buttons. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML 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.
.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.
| Hook | Values | Default | Contract |
|---|---|---|---|
| class, className | string | "" | 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.
| Key | Action |
|---|---|
| Tab | Move between Copy, Retry, and the two rating buttons. |
| Enter / Space | Copy 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.
| Event | Target | Detail | When |
|---|---|---|---|
| ui:message-retry | MessageActions 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-feedback | MessageActions 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. |