Skip to content
+

Chat - Message actions

Reveal per-message action buttons on hover or focus for copy, edit, delete, and custom operations.

ChatMessageActions renders an action bar that appears on hover, on keyboard drill-in (Enter on the focused message), or while focus is inside the bar. The actions area occupies the actions grid area of the message row; the reveal uses a short opacity transition.

Playground

Toggle action buttons, variant, and density to preview the hover-revealed toolbar:

ChatMessageActions
Hover-revealed action toolbar (copy, regenerate, react…) anchored under the bubble.

MUI Assistant
MUI Assistant

Toggle "reveal actions", or hover this bubble.

composition (children)
copy action
like action
visibility
reveal actions
chrome provider
ChatChrome.variantenum · 2
ChatChrome.densityenum · 3

Import

import { ChatMessageActions } from '@mui/x-chat';

Visibility behavior

The action bar is hidden by default and becomes visible when:

  • The user hovers over the parent ChatMessage row
  • The user drills into the focused message with Enter (the message list sets data-actionable="true" on the row — see keyboard navigation)
  • Focus is inside the action bar itself (:focus-within)

While hidden, the bar uses visibility: hidden in addition to opacity: 0, so the action buttons are removed from the tab order and from hit-testing — tabbing through the chat never stops on an invisible control. The reveal uses a short opacity transition; when the user prefers reduced motion, the transition is disabled.

/* Selectors used by the built-in styles */
.MuiChatMessage-root:hover .MuiChatMessage-actions,
.MuiChatMessage-root[data-actionable='true'] .MuiChatMessage-actions,
.MuiChatMessage-actions:focus-within {
  opacity: 1;
  visibility: visible;
}

Component anatomy

ChatMessageActions occupies the actions grid area in the message row layout:

ChatMessage (grid)
  ├── ChatMessageAvatar    → grid-area: avatar
  ├── ChatMessageContent   → grid-area: content
  ├── ChatMessageMeta      → grid-area: meta
  └── ChatMessageActions   → grid-area: actions

The built-in styles render the bar as a small elevated chip (paper background, rounded corners, shadow) anchored under the bubble. For the current user's own messages it aligns to the end of the row (justify-self: end), matching the right-aligned bubble. Override either through the .MuiChatMessage-actions class.

Adding custom actions

ChatMessageActions renders a <div> (or custom slot element) that you populate with action buttons. When using ChatBox, provide the messageActions slot to render an action row — ChatBox renders no actions until you do. Your component receives { messageId } and is wrapped in the styled hover-revealed bar:

Material UI chat

Styled with your active MUI theme

MUI Assistant
MUI Assistant

Hello! I am styled using your active Material UI theme. Try sending a message.

You
You

Great — the bubble colors come from palette.primary and the typography from the theme.

Accessing message context

The component you pass to the messageActions slot receives a messageId prop. Pass it to the useMessage() hook (exported from @mui/x-chat/headless) to read the current message and show different actions for user and assistant messages. Reach the runtime actions with useChatActions()—it returns sendMessage, retry, regenerate, and the rest without subscribing to message state, so the toolbar does not re-render while a response streams:

Material UI chat

Styled with your active MUI theme

MUI Assistant
MUI Assistant

Hello! I am styled using your active Material UI theme. Try sending a message.

You
You

Great — the bubble colors come from palette.primary and the typography from the theme.

Adding actions declaratively

Instead of replacing the messageActions slot component, pass a function to slotProps.messageActions and return extraActions. The function receives the message context, so you can target specific rows—for example, a working "Regenerate" button on assistant replies. Each action's onClick receives (event, { message, chat }); call chat.regenerate(message.id) to request a fresh reply through the runtime:

Material UI chat

Styled with your active MUI theme

MUI Assistant
MUI Assistant

Hello! I am styled using your active Material UI theme. Try sending a message.

You
You

Great — the bubble colors come from palette.primary and the typography from the theme.

Owner state

The standalone ChatMessageActions component forwards the message context as owner state to its actions slot, so slot components can style themselves conditionally (when using the ChatBox messageActions slot, read the same data with useMessage(messageId) instead):

Property Type Description
messageId string ID of the current message
message ChatMessage | null The full message object, or null if not found
role ChatRole | undefined Role of the message author (undefined until resolved)
status ChatMessageStatus | undefined Current status of the message (undefined until resolved)
streaming boolean Whether the message is streaming
error boolean Whether the message is in an error state
isGrouped boolean Whether the message is in a group
variant ChatVariant Current chrome variant
density ChatDensity Current chrome density
resolvedAuthor ResolvedMessageAuthor | null Resolved author display data
showAvatar boolean Whether an avatar column is rendered
isOwnMessage boolean Whether the message belongs to the current user (controls right-side alignment)

Slots

Slot Default element Description
actions div The action bar container

See also

API

See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.