PeakUIPro

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 .button classes

Slots

  • [data-slot="chat-message-actions"]
  • [data-slot="chat-message-actions-action"]

CSS Variables

VariablePurpose
--chat-message-actions-gapSpace 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: :hover or [data-hovered]
  • Pressed: :active or [data-pressed]
  • Focus: :focus-visible or [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 keeps ButtonText and a disabled one is dimmed

API Reference

ChatMessageActions

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes

ChatMessageActions.Action

PropTypeDefaultDescription
childrenReact.ReactNode | (values: ButtonRenderProps) => React.ReactNode-The icon you bring; the package ships none
aria-labelstring"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
isIconOnlybooleantrueSquare 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
isDisabledbooleanfalseWhether the action is disabled
onPress(e: PressEvent) => void-Handler called when the action is pressed
classNamestring | (values: ButtonRenderProps) => string-Additional classes, or a function of the button's state
renderDOMRenderFunction<'button', ButtonRenderProps>-Replaces the rendered element; receives the props with data-slot set
...restButtonProps-Every other core Button prop

Render Props

PropTypeDescription
isPendingbooleanWhether the action is waiting on an operation
isPressedbooleanWhether the action is currently pressed
isHoveredbooleanWhether the action is hovered
isFocusedbooleanWhether the action is focused
isFocusVisiblebooleanWhether the action is focused by keyboard
isDisabledbooleanWhether the action is disabled

On this page