Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
AI Integration Quick Reference
Where It Fits
CometChatContextMenu is a base component used as the overflow action menu across the UI Kit. It appears on message bubbles, conversation list items, group member rows, user list items, and message headers. It splits actions into a visible top row of icon buttons and a dropdown for the rest.
Minimal Render
.cometchat-context-menu
Sub-Components
CometChatContextMenu is a compound component with four sub-components:
| Sub-component | Purpose |
|---|---|
Root | Container that provides context, orchestrates top-row items and dropdown. |
Item | A single action rendered as a button. Supports icon (top-row) and full (dropdown) variants. |
Trigger | The “more” button that toggles the dropdown. |
Dropdown | The overflow popover with keyboard navigation and focus trap. |
Root
The outermost wrapper. In data-driven mode, passitems and topMenuSize and it renders everything automatically. For full control, pass children instead.
- Data-driven
- Fully composed
Item
Renders a single action. Inicon variant, it shows only the icon with an aria-label. In full variant, it shows icon + title and uses role="menuitem".
Trigger
The “more” button. Renders a vertical ellipsis icon by default. Passchildren for a custom trigger.
Dropdown
The overflow popover. Positioned relative to the root container using theplacement prop. Includes full keyboard navigation and a focus trap.
Actions and Events
Callback Props
onOptionClicked
Called when any menu item is selected (top-row or dropdown). Receives the fullCometChatContextMenuItemData object. When provided, overrides individual item.onClick callbacks.
Custom View Slots
| Slot | Signature | Replaces |
|---|---|---|
children on Root | ReactNode | Entire auto-generated layout (top-row + trigger + dropdown) |
children on Trigger | ReactNode | Default “more” icon |
children on Dropdown | ReactNode | Auto-generated dropdown items |
Custom trigger content
Common Patterns
Message bubble options
All items in dropdown (no top row)
All items in top row (no dropdown)
Keyboard Navigation
The context menu is fully keyboard-accessible:| Key | Behavior |
|---|---|
Tab | Moves focus between top-row items and the trigger button |
Enter / Space | On top-row item: activates it. On trigger: toggles dropdown |
ArrowDown | On trigger: opens dropdown. In dropdown: moves to next item (wraps) |
ArrowUp | In dropdown: moves to previous item (wraps) |
Home | In dropdown: moves focus to first item |
End | In dropdown: moves focus to last item |
Escape | Closes dropdown and returns focus to trigger |
Tab (in dropdown) | Cycles within dropdown items (focus trap) |
CSS Architecture
The component uses CSS custom properties (design tokens) defined in@cometchat/chat-uikit-react/css-variables.css. The cascade:
- Global tokens set on the
.cometchatroot wrapper. - Component CSS (
.cometchat-context-menu) consumes these tokens viavar(). - Overrides target
.cometchat-context-menudescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root container | .cometchat-context-menu |
| Top menu row | .cometchat-context-menu__top-menu |
| Top menu item | .cometchat-context-menu__top-menu-item |
| Top menu item icon | .cometchat-context-menu__top-menu-item-icon |
| Trigger button | .cometchat-context-menu__trigger |
| Trigger icon | .cometchat-context-menu__trigger-icon |
| Dropdown | .cometchat-context-menu__dropdown |
| Dropdown item | .cometchat-context-menu__dropdown-item |
| Dropdown item icon | .cometchat-context-menu__dropdown-item-icon |
| Dropdown item title | .cometchat-context-menu__dropdown-item-title |
Example: Brand-themed context menu
App.css
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Menu items | Component props | items on Root | <Root items={myItems}> |
| Top row count | Component props | topMenuSize on Root | <Root topMenuSize={3}> |
| Dropdown position | Component props | placement on Root or Dropdown | <Root placement="bottom"> |
| Handle selection | Component props | onOptionClicked on Root | <Root onOptionClicked={handler}> |
| Disable an item | Item data | disabled on CometChatContextMenuItemData | { disabled: true } |
| Custom trigger | Sub-component | children on Trigger | <Trigger><MyIcon /></Trigger> |
| Change visual styling | Global CSS | .cometchat-context-menu selectors | See example above |
Props
All props are optional unless noted otherwise.CometChatContextMenu.Root
items
Array of menu item data objects. When provided withoutchildren, the component auto-renders top-row items and dropdown.
| Type | CometChatContextMenuItemData[] |
| Default | [] |
topMenuSize
Number of items visible in the top row. Remaining items go to the dropdown. When0, all items are in the dropdown. When >= items.length, no dropdown is rendered.
| Type | number |
| Default | 2 |
onOptionClicked
Called when any menu item is selected. Receives the full item data object. When provided, overrides individualitem.onClick callbacks.
| Type | (item: CometChatContextMenuItemData) => void |
| Default | undefined |
placement
Position of the dropdown relative to the trigger.| Type | 'top' | 'right' | 'bottom' | 'left' |
| Default | 'left' |
moreButtonTooltip
Tooltip text for the “more” trigger button.| Type | string |
| Default | undefined |
closeOnOutsideClick
Whether clicking outside the component closes the dropdown.| Type | boolean |
| Default | true |
className
Custom CSS class appended to the root container.| Type | string |
| Default | undefined |
children
Custom content. When provided, overrides the data-driven rendering entirely.| Type | ReactNode |
| Default | undefined |
CometChatContextMenu.Item
item
The menu item data object.| Type | CometChatContextMenuItemData |
| Default | undefined |
variant
Display mode.icon renders icon-only (for top row). full renders icon + title (for dropdown).
| Type | 'icon' | 'full' |
| Default | 'full' |
className
Custom CSS class appended to the item button.| Type | string |
| Default | undefined |
CometChatContextMenu.Trigger
tooltip
Tooltip andaria-label text for the trigger button.
| Type | string |
| Default | undefined |
className
Custom CSS class appended to the trigger button.| Type | string |
| Default | undefined |
children
Custom trigger content. Replaces the default vertical ellipsis icon.| Type | ReactNode |
| Default | undefined |
CometChatContextMenu.Dropdown
placement
Position of the dropdown. Overrides the value fromRoot context.
| Type | 'top' | 'right' | 'bottom' | 'left' |
| Default | inherited from Root |
className
Custom CSS class appended to the dropdown container.| Type | string |
| Default | undefined |
children
Dropdown content. TypicallyCometChatContextMenu.Item elements with variant="full".
| Type | ReactNode |
| Default | undefined |
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-context-menu |
| Top menu row | .cometchat-context-menu__top-menu |
| Top menu item | .cometchat-context-menu__top-menu-item |
| Top menu item icon | .cometchat-context-menu__top-menu-item-icon |
| Trigger button | .cometchat-context-menu__trigger |
| Trigger icon | .cometchat-context-menu__trigger-icon |
| Dropdown | .cometchat-context-menu__dropdown |
| Dropdown (top) | .cometchat-context-menu__dropdown--top |
| Dropdown (right) | .cometchat-context-menu__dropdown--right |
| Dropdown (bottom) | .cometchat-context-menu__dropdown--bottom |
| Dropdown (left) | .cometchat-context-menu__dropdown--left |
| Dropdown item | .cometchat-context-menu__dropdown-item |
| Dropdown item (disabled) | .cometchat-context-menu__dropdown-item--disabled |
| Dropdown item icon | .cometchat-context-menu__dropdown-item-icon |
| Dropdown item title | .cometchat-context-menu__dropdown-item-title |