Chat Message Actions
Icon action row under a chat message for copying, rating, regenerating and opening more options.
Description
ChatMessageActions is a compound component that renders a horizontal <div> of icon-only buttons. It ships presets for the actions almost every AI chat needs: Copy writes to the clipboard and swaps to a check, ThumbsUp and ThumbsDown are toggle buttons that can share one rating through Feedback, Regenerate reruns a response and Menu opens an overflow dropdown. Action is the bare button for anything else.
Put it under an assistant response or a user bubble. By default the row sits at 75% opacity and comes up to full strength when the message is hovered, focused, or has an open menu, so a long conversation does not turn into a wall of icons.
Don't use it for a toolbar with labelled buttons or form controls; use Button in a flex row, or Button Group when the buttons are visually joined. For a single standalone copy button outside a chat, a Button with your own clipboard handler is lighter. For suggested follow-up prompts, use Prompt Suggestion.
ChatMessageActions is a Create UI Pro component. Install it with a Pro seat.
Installation
Anatomy
Usage
Examples
Every example is a Pro preview (marked with a Pro badge).
Presets
Each preset brings its icon and an English accessible name ("Copy message", "Good response", "Bad response", "Regenerate response", "More actions"). Pass aria-label to translate or make it more specific.
Sizes
size is set per action and takes sm (24px, the default), md (32px) or lg (40px). The glyph follows the button, so the copy check and the filled thumbs scale with it. There is no xs, because 20px is under the minimum touch target.
Appearance
Actions are Buttons with variant="neutral-light" and appearance="ghost" by default. outline and soft work when the row sits on a busy surface and needs visible hit areas.
Copy
Give Copy a value (or a function that returns one) and it writes the text with the Clipboard API. The check only appears after the write succeeds, stays for two seconds, and "Copied" is announced to screen readers. onCopy and onCopyError report the result.
Pass copied to drive the check yourself, for example when the copy happens somewhere else. In controlled mode the component never resets it.
Feedback
Wrap the thumbs in Feedback to keep one rating: value is "up", "down" or null, and pressing the active thumb again clears it. Pressed thumbs switch to the filled glyph and set aria-pressed.
Outside a Feedback group each thumb is an independent toggle with pressed, defaultPressed and onPressedChange.
Custom actions
Action takes any icon and a required aria-label. Presets also accept a child icon, and the thumbs take pressedIcon, so a thumb can become a bookmark toggle without writing the pressed logic again.
Overflow menu
Menu is a plain action, so it drops straight into Dropdown as the trigger. While the menu is open the row stays at full opacity even though focus has moved into the popover.
Hover reveal
Inside ChatMessage.Assistant or ChatMessage.User, reveal="hover" (the default) keys off the whole message row, not just the action strip. Hover the message or tab into it to bring the row up. Use reveal="always" for the latest message or on touch-first layouts.
Accessibility
ARIA notes:
- Every action renders a native
<button>.Actionrequiresaria-label; presets ship a default name you can override. Copyswitches its accessible name tocopiedLabelwhile the check shows, and a visually hiddenrole="status"region next to it announces the same text.ThumbsUpandThumbsDownsetaria-pressed.Feedbackrendersrole="group"with the label"Rate this response"; passaria-labelto change it.- Preset glyphs are
aria-hidden, so only the button name is read. Icons you pass toActionare covered by itsaria-labeltoo. reveal="hover"only lowers opacity. Actions stay in the tab order and the accessibility tree, and the row reaches full opacity on:focus-within.- The icon cross-fade drops its scale and blur under
prefers-reduced-motionand keeps only a short opacity fade. tooltipuses the Radix Tooltip, which opens on focus as well as hover. See the Radix Tooltip docs.
Styling
Tailwind override: pass className to the root for spacing and to any action to restyle one button.
Data slots and attributes: the component sets these for CSS targeting:
data-slot="chat-message-actions"on the root, withdata-reveal("hover"or"always").data-slot="chat-message-action"on every button, with theButtonattributesdata-variant,data-appearanceanddata-size.data-actionon each preset:"copy","thumbs-up","thumbs-down","regenerate"or"menu".data-copiedonCopywhile the check shows, anddata-pressedplusaria-pressed="true"on a pressed thumb.data-slot="chat-message-action-icon"on the glyph wrapper ofCopyand the thumbs, withdata-state("idle"/"copied"for copy,"off"/"on"for thumbs).data-slot="chat-message-action-status"on the hidden live region next toCopy.data-slot="chat-message-actions-feedback"on theFeedbackgroup, withdata-value("up","down"or"none").
Related Components
- Chat Message: the message layout these actions sit under. It marks the row that
reveal="hover"listens to. - Button: use it for labelled or standalone actions outside a message.
- Dropdown Menu: pairs with
Menufor actions that do not deserve their own icon. - Tooltip: what the
tooltipprop renders. Reach for it directly if you need a different variant or side.
API Reference
ChatMessageActions
The row. Extends React.ComponentProps<"div">. Also available as ChatMessageActions.Root and ChatMessageActionsRoot.
Props
Variants
ChatMessageActions.Action
An icon-only action. Renders Button with iconOnly, so it extends the Button props (disabled, loading, asChild, onClick and every native button attribute) except iconOnly. Also exported as ChatMessageAction.
Props
Variants
ChatMessageActions.Copy
Copies text to the clipboard and swaps its glyph to a check. Takes every Action prop, with aria-label optional (default "Copy message"). The native value and onCopy button attributes are replaced by the props below.
Props
Calling event.preventDefault() inside onClick skips the copy.
ChatMessageActions.Feedback
Holds one rating for the ThumbsUp and ThumbsDown inside it. Extends React.ComponentProps<"div"> and renders role="group".
Props
ChatMessageActions.ThumbsUp / ChatMessageActions.ThumbsDown
Toggle buttons for rating a response. Take every Action prop, with aria-label optional (defaults "Good response" and "Bad response"). Inside Feedback the pressed state comes from the group and pressed / defaultPressed are ignored.
Props
ChatMessageActions.Regenerate / ChatMessageActions.Menu
Plain presets with a default glyph. Take every Action prop, with aria-label optional (defaults "Regenerate response" and "More actions"). Use loading on Regenerate while a new answer streams, and put Menu directly inside Dropdown as its trigger.
Props
Types
chatMessageActionsVariants is the CVA recipe for the root, exported for composing your own row.