ChatMessageActions
Row of icon buttons beneath a chat message
Usage
import {ChatMessageActions} from "@peakui-pro/react";Anatomy
import {ChatMessageActions} from "@peakui-pro/react";
export default () => (
<ChatMessageActions>
<ChatMessageActions.Action aria-label="Copy">...</ChatMessageActions.Action>
<ChatMessageActions.Action aria-label="Like">...</ChatMessageActions.Action>
</ChatMessageActions>
);Examples
Minimal
Use fewer actions when the layout is tight.
Custom Icons
Bring any icon set; the glyph keeps its own color.
Disabled
isDisabled dims one action and takes it out of the tab order.
With Text
isIconOnly={false} drops the default name; add text or aria-label.
Customization
Tailwind CSS
<ChatMessageActions className="[--chat-message-actions-gap:4px]">
<ChatMessageActions.Action aria-label="Copy" className="[--button-radius:var(--radius-md)]">
<Copy />
</ChatMessageActions.Action>
</ChatMessageActions>Global CSS
@layer components {
.chat-message-actions {
--chat-message-actions-gap: 4px;
}
.chat-message-actions__action {
--button-radius: var(--radius-md);
}
}Styling Reference
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
CSS Classes
The ChatMessageActions component uses these CSS classes (view source styles):
Base Classes
.chat-message-actions- Action row
Element Classes
.chat-message-actions__action- Icon button, beside the core.buttonclasses
Slots
[data-slot="chat-message-actions"][data-slot="chat-message-actions-action"]
CSS Variables
| Variable | Purpose |
|---|---|
--chat-message-actions-gap | Space between actions; defaults to 0px, set on .chat-message-actions |
Interactive States
The action rests in the muted text color and returns to the foreground on these:
- Hover:
:hoveror[data-hovered] - Pressed:
:activeor[data-pressed] - Focus:
:focus-visibleor[data-focus-visible] - Disabled:
:disabled,[data-disabled]or[aria-disabled="true"], dimmed by the core button - Forced colors:
@media (forced-colors: active)drops the muted tone, so an enabled action keepsButtonTextand a disabled one is dimmed
API Reference
ChatMessageActions
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
...rest | ComponentProps<'div'> | - | Native <div> attributes |
ChatMessageActions.Action
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | (values: ButtonRenderProps) => React.ReactNode | - | The icon you bring; the package ships none |
aria-label | string | "Message action" | Accessible name. The default applies only while isIconOnly is true; with isIconOnly={false} visible text is the name, and an icon without text or label has none |
isIconOnly | boolean | true | Square button for one icon; set false to show text beside it |
variant | 'primary' | 'secondary' | 'tertiary' | 'outline' | 'ghost' | 'danger' | 'danger-soft' | 'ghost' | Core button style |
size | 'sm' | 'md' | 'lg' | 'sm' | Core button size |
isDisabled | boolean | false | Whether the action is disabled |
onPress | (e: PressEvent) => void | - | Handler called when the action is pressed |
className | string | (values: ButtonRenderProps) => string | - | Additional classes, or a function of the button's state |
render | DOMRenderFunction<'button', ButtonRenderProps> | - | Replaces the rendered element; receives the props with data-slot set |
...rest | ButtonProps | - | Every other core Button prop |
Render Props
| Prop | Type | Description |
|---|---|---|
isPending | boolean | Whether the action is waiting on an operation |
isPressed | boolean | Whether the action is currently pressed |
isHovered | boolean | Whether the action is hovered |
isFocused | boolean | Whether the action is focused |
isFocusVisible | boolean | Whether the action is focused by keyboard |
isDisabled | boolean | Whether the action is disabled |