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
CometChatChangeScope is a base component used by CometChatGroupMembers when a group owner or admin needs to change another member’s role. It renders a self-contained dialog with a radio group, confirm/cancel buttons, and automatic loading/error handling driven by the onScopeChanged promise.
Minimal Render
.cometchat-change-scope
Sub-Components
CometChatChangeScope is a compound component with six sub-components:
| Sub-component | Purpose |
|---|---|
Root | Dialog container. Provides context, focus trap, keyboard handling, and state management. |
Header | Icon, title, and description text. |
ScopeList | Radio group container with role="radiogroup". |
ScopeOption | A single radio option representing a scope level. |
Actions | Cancel and submit buttons. Submit is disabled until the selection changes. |
ErrorMessage | Displays an error message (with role="alert") when scope change fails. |
Root
The outermost wrapper. Initializes theuseCometChatChangeScope hook, provides context to all children, traps focus within the dialog, and handles Escape to close.
Header
Renders a scope icon, title, and description. All text defaults to localized strings but can be overridden via props. SetshowIcon={false} to hide the icon.
ScopeList
A container withrole="radiogroup". Wrap ScopeOption children inside it.
ScopeOption
A single radio input with a label. Reads context to determine if it is the currently selected option.Actions
Cancel and submit buttons. The submit button is automatically disabled when the selection matchesdefaultSelection or while loading. Shows a spinner during the async onScopeChanged call.
ErrorMessage
Renders only when theonScopeChanged promise rejects. Uses role="alert" so screen readers announce the error immediately.
Common Patterns
Async scope change with SDK
Custom header without icon
Without error message display
Omit theErrorMessage sub-component if you handle errors externally:
Keyboard Navigation
The change scope dialog is fully keyboard-accessible:| Key | Behavior |
|---|---|
Tab | Moves focus to the next focusable element (trapped within the dialog) |
Shift+Tab | Moves focus to the previous focusable element (wraps around) |
Escape | Closes the dialog and returns focus to the trigger element |
Enter / Space | Selects the focused radio option or activates a button |
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-change-scope) consumes these tokens viavar(). - Overrides target
.cometchat-change-scopedescendant selectors.
Key Selectors
| Target | Selector |
|---|---|
| Root container | .cometchat-change-scope |
| Header wrapper | .cometchat-change-scope__header |
| Icon container | .cometchat-change-scope__icon-container |
| Icon | .cometchat-change-scope__icon |
| Title | .cometchat-change-scope__title |
| Description | .cometchat-change-scope__description |
| Radio group list | .cometchat-change-scope__list |
| List item (option row) | .cometchat-change-scope__list-item |
| Option label text | .cometchat-change-scope__list-item-label |
| Radio input | .cometchat-change-scope__radio |
| Button container | .cometchat-change-scope__button-container |
| Cancel button wrapper | .cometchat-change-scope__cancel-button |
| Submit button wrapper | .cometchat-change-scope__submit-button |
| Error message | .cometchat-change-scope__error-view |
Example: Brand-themed change scope dialog
App.css
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Scope options | Component props | options on Root | <Root options={[...]}> |
| Default selection | Component props | defaultSelection on Root | <Root defaultSelection="admin"> |
| Handle scope change | Component props | onScopeChanged on Root | <Root onScopeChanged={fn}> |
| Header text | Component props | title, description on Header | <Header title="Update Role"> |
| Hide icon | Component props | showIcon on Header | <Header showIcon={false}> |
| Button labels | Component props | submitText, cancelText on Actions | <Actions submitText="Update"> |
| Hide error display | Composition | Omit ErrorMessage sub-component | Don’t render <ErrorMessage /> |
| Change visual styling | Global CSS | .cometchat-change-scope selectors | See example above |
Props
All props are optional unless noted otherwise.CometChatChangeScope.Root
options
Array of scope options to display in the radio group.| Type | CometChatChangeScopeOptionData[] |
| Default | undefined |
defaultSelection
Theid of the initially selected scope option. The submit button stays disabled until the user selects a different option.
| Type | string |
| Default | '' |
onScopeChanged
Called when the user clicks the submit button. Receives the selected scopeid. Return a Promise — the component shows a loading spinner while it resolves and displays an error if it rejects.
| Type | (scopeId: string) => Promise<void> |
| Default | undefined |
onClose
Called when the user clicks cancel or presses Escape. Also called automatically after a successfulonScopeChanged resolution.
| Type | () => void |
| Default | undefined |
className
Custom CSS class appended to the root container.| Type | string |
| Default | undefined |
children
Content rendered inside the dialog. TypicallyHeader, ScopeList, ErrorMessage, and Actions sub-components.
| Type | ReactNode |
| Default | undefined |
CometChatChangeScope.Header
title
Title text displayed in the header. Defaults to the localized “Change Scope” string.| Type | string |
| Default | Localized "Change Scope" |
description
Description text below the title. Defaults to the localized subtitle.| Type | string |
| Default | Localized subtitle |
showIcon
Whether to display the scope icon above the title.| Type | boolean |
| Default | true |
className
Custom CSS class appended to the header container.| Type | string |
| Default | undefined |
CometChatChangeScope.ScopeList
className
Custom CSS class appended to the radio group container.| Type | string |
| Default | undefined |
children
TheScopeOption sub-components to render.
| Type | ReactNode |
| Default | undefined |
CometChatChangeScope.ScopeOption
option
The scope option data object.| Type | CometChatChangeScopeOptionData |
| Default | undefined |
className
Custom CSS class appended to the option row.| Type | string |
| Default | undefined |
CometChatChangeScope.Actions
submitText
Text for the submit button. Defaults to the localized “Save” string.| Type | string |
| Default | Localized "Save" |
cancelText
Text for the cancel button. Defaults to the localized “Cancel” string.| Type | string |
| Default | Localized "Cancel" |
className
Custom CSS class appended to the button container.| Type | string |
| Default | undefined |
CometChatChangeScope.ErrorMessage
className
Custom CSS class appended to the error message container.| Type | string |
| Default | undefined |
CSS Selectors
| Target | Selector |
|---|---|
| Root | .cometchat-change-scope |
| Header | .cometchat-change-scope__header |
| Icon container | .cometchat-change-scope__icon-container |
| Icon | .cometchat-change-scope__icon |
| Title | .cometchat-change-scope__title |
| Description | .cometchat-change-scope__description |
| Radio group | .cometchat-change-scope__list |
| Option row | .cometchat-change-scope__list-item |
| Option label | .cometchat-change-scope__list-item-label |
| Radio input | .cometchat-change-scope__radio |
| Button container | .cometchat-change-scope__button-container |
| Cancel button | .cometchat-change-scope__cancel-button |
| Submit button | .cometchat-change-scope__submit-button |
| Error message | .cometchat-change-scope__error-view |