Skip to main content

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.

{
  "component": "CometChatChangeScope",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatChangeScope } from \"@cometchat/chat-uikit-react\";",
  "cssImport": "import \"@cometchat/chat-uikit-react/css-variables.css\";",
  "description": "A dialog component for changing a group member's scope with radio selection, async confirmation, and built-in loading/error states.",
  "cssRootClass": ".cometchat-change-scope",
  "subComponents": ["Root", "Header", "ScopeList", "ScopeOption", "Actions", "ErrorMessage"],
  "props": {
    "Root": {
      "options": { "type": "CometChatChangeScopeOptionData[]", "default": "undefined", "note": "Required." },
      "defaultSelection": { "type": "string", "default": "''" },
      "onScopeChanged": { "type": "(scopeId: string) => Promise<void>", "default": "undefined" },
      "onClose": { "type": "() => void", "default": "undefined" },
      "className": { "type": "string", "default": "undefined" },
      "children": { "type": "ReactNode", "default": "undefined" }
    },
    "Header": {
      "title": { "type": "string", "default": "Localized 'Change Scope'" },
      "description": { "type": "string", "default": "Localized subtitle" },
      "showIcon": { "type": "boolean", "default": "true" },
      "className": { "type": "string", "default": "undefined" }
    },
    "ScopeList": {
      "className": { "type": "string", "default": "undefined" },
      "children": { "type": "ReactNode", "default": "undefined" }
    },
    "ScopeOption": {
      "option": { "type": "CometChatChangeScopeOptionData", "default": "undefined", "note": "Required." },
      "className": { "type": "string", "default": "undefined" }
    },
    "Actions": {
      "submitText": { "type": "string", "default": "Localized 'Save'" },
      "cancelText": { "type": "string", "default": "Localized 'Cancel'" },
      "className": { "type": "string", "default": "undefined" }
    },
    "ErrorMessage": {
      "className": { "type": "string", "default": "undefined" }
    }
  },
  "types": {
    "CometChatChangeScopeOptionData": {
      "id": "string",
      "label": "string"
    },
    "CometChatChangeScopeContextValue": {
      "options": "CometChatChangeScopeOptionData[]",
      "selectedId": "string",
      "defaultSelection": "string",
      "isLoading": "boolean",
      "error": "string | null",
      "selectOption": "(id: string) => void",
      "confirmChange": "() => void",
      "cancel": "() => void",
      "hasChanged": "boolean"
    }
  }
}

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.
import { CometChatChangeScope } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

const scopeOptions = [
  { id: "admin", label: "Admin" },
  { id: "moderator", label: "Moderator" },
  { id: "participant", label: "Participant" },
];

function GroupMemberScopeDialog({ currentScope, onScopeChanged, onClose }) {
  return (
    <CometChatChangeScope.Root
      options={scopeOptions}
      defaultSelection={currentScope}
      onScopeChanged={onScopeChanged}
      onClose={onClose}
    >
      <CometChatChangeScope.Header />
      <CometChatChangeScope.ScopeList>
        {scopeOptions.map((opt) => (
          <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
        ))}
      </CometChatChangeScope.ScopeList>
      <CometChatChangeScope.ErrorMessage />
      <CometChatChangeScope.Actions />
    </CometChatChangeScope.Root>
  );
}

Minimal Render

import { CometChatChangeScope } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

const options = [
  { id: "admin", label: "Admin" },
  { id: "moderator", label: "Moderator" },
  { id: "participant", label: "Participant" },
];

function Demo() {
  return (
    <CometChatChangeScope.Root options={options} defaultSelection="participant">
      <CometChatChangeScope.Header />
      <CometChatChangeScope.ScopeList>
        {options.map((opt) => (
          <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
        ))}
      </CometChatChangeScope.ScopeList>
      <CometChatChangeScope.Actions />
    </CometChatChangeScope.Root>
  );
}
Root CSS class: .cometchat-change-scope

Sub-Components

CometChatChangeScope is a compound component with six sub-components:
Sub-componentPurpose
RootDialog container. Provides context, focus trap, keyboard handling, and state management.
HeaderIcon, title, and description text.
ScopeListRadio group container with role="radiogroup".
ScopeOptionA single radio option representing a scope level.
ActionsCancel and submit buttons. Submit is disabled until the selection changes.
ErrorMessageDisplays an error message (with role="alert") when scope change fails.

Root

The outermost wrapper. Initializes the useCometChatChangeScope hook, provides context to all children, traps focus within the dialog, and handles Escape to close.
<CometChatChangeScope.Root
  options={scopeOptions}
  defaultSelection="participant"
  onScopeChanged={async (scopeId) => {
    await CometChat.updateGroupMemberScope(groupId, memberId, scopeId);
  }}
  onClose={() => setShowDialog(false)}
>
  {/* Header, ScopeList, ErrorMessage, Actions */}
</CometChatChangeScope.Root>
Renders a scope icon, title, and description. All text defaults to localized strings but can be overridden via props. Set showIcon={false} to hide the icon.
<CometChatChangeScope.Header
  title="Update Role"
  description="Select a new role for this member."
  showIcon={false}
/>

ScopeList

A container with role="radiogroup". Wrap ScopeOption children inside it.
<CometChatChangeScope.ScopeList>
  {options.map((opt) => (
    <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
  ))}
</CometChatChangeScope.ScopeList>

ScopeOption

A single radio input with a label. Reads context to determine if it is the currently selected option.
<CometChatChangeScope.ScopeOption
  option={{ id: "admin", label: "Admin" }}
/>

Actions

Cancel and submit buttons. The submit button is automatically disabled when the selection matches defaultSelection or while loading. Shows a spinner during the async onScopeChanged call.
<CometChatChangeScope.Actions submitText="Update" cancelText="Dismiss" />

ErrorMessage

Renders only when the onScopeChanged promise rejects. Uses role="alert" so screen readers announce the error immediately.
<CometChatChangeScope.ErrorMessage />

Common Patterns

Async scope change with SDK

import { CometChatChangeScope } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";
import { CometChat } from "@cometchat/chat-sdk-javascript";

const scopeOptions = [
  { id: "admin", label: "Admin" },
  { id: "moderator", label: "Moderator" },
  { id: "participant", label: "Participant" },
];

function ChangeScopeDialog({ groupGuid, memberUid, currentScope, onClose }) {
  const handleScopeChanged = async (scopeId: string) => {
    await CometChat.updateGroupMemberScope(groupGuid, memberUid, scopeId);
  };

  return (
    <CometChatChangeScope.Root
      options={scopeOptions}
      defaultSelection={currentScope}
      onScopeChanged={handleScopeChanged}
      onClose={onClose}
    >
      <CometChatChangeScope.Header />
      <CometChatChangeScope.ScopeList>
        {scopeOptions.map((opt) => (
          <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
        ))}
      </CometChatChangeScope.ScopeList>
      <CometChatChangeScope.ErrorMessage />
      <CometChatChangeScope.Actions />
    </CometChatChangeScope.Root>
  );
}

Custom header without icon

<CometChatChangeScope.Root options={options} defaultSelection="participant">
  <CometChatChangeScope.Header
    title="Member Role"
    description="Choose the appropriate role."
    showIcon={false}
  />
  <CometChatChangeScope.ScopeList>
    {options.map((opt) => (
      <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
    ))}
  </CometChatChangeScope.ScopeList>
  <CometChatChangeScope.Actions />
</CometChatChangeScope.Root>

Without error message display

Omit the ErrorMessage sub-component if you handle errors externally:
<CometChatChangeScope.Root
  options={options}
  defaultSelection="participant"
  onScopeChanged={handleChange}
  onClose={onClose}
>
  <CometChatChangeScope.Header />
  <CometChatChangeScope.ScopeList>
    {options.map((opt) => (
      <CometChatChangeScope.ScopeOption key={opt.id} option={opt} />
    ))}
  </CometChatChangeScope.ScopeList>
  <CometChatChangeScope.Actions />
</CometChatChangeScope.Root>

Keyboard Navigation

The change scope dialog is fully keyboard-accessible:
KeyBehavior
TabMoves focus to the next focusable element (trapped within the dialog)
Shift+TabMoves focus to the previous focusable element (wraps around)
EscapeCloses the dialog and returns focus to the trigger element
Enter / SpaceSelects the focused radio option or activates a button
When the dialog mounts, focus automatically moves to the first focusable element. When it unmounts, focus returns to the element that had focus before the dialog opened.

CSS Architecture

The component uses CSS custom properties (design tokens) defined in @cometchat/chat-uikit-react/css-variables.css. The cascade:
  1. Global tokens set on the .cometchat root wrapper.
  2. Component CSS (.cometchat-change-scope) consumes these tokens via var().
  3. Overrides target .cometchat-change-scope descendant selectors.

Key Selectors

TargetSelector
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
.cometchat-change-scope {
  border-radius: 12px;
  border-color: var(--brand-border);
}

.cometchat-change-scope__icon-container {
  background: var(--brand-surface-light);
}

.cometchat-change-scope__list-item:hover {
  background: var(--brand-hover);
}

.cometchat-change-scope__error-view {
  background: var(--brand-error-bg);
  color: var(--brand-error-text);
}

Customization Matrix

What to changeWhereProperty/APIExample
Scope optionsComponent propsoptions on Root<Root options={[...]}>
Default selectionComponent propsdefaultSelection on Root<Root defaultSelection="admin">
Handle scope changeComponent propsonScopeChanged on Root<Root onScopeChanged={fn}>
Header textComponent propstitle, description on Header<Header title="Update Role">
Hide iconComponent propsshowIcon on Header<Header showIcon={false}>
Button labelsComponent propssubmitText, cancelText on Actions<Actions submitText="Update">
Hide error displayCompositionOmit ErrorMessage sub-componentDon’t render <ErrorMessage />
Change visual stylingGlobal CSS.cometchat-change-scope selectorsSee example above

Props

All props are optional unless noted otherwise.

CometChatChangeScope.Root

options

Array of scope options to display in the radio group.
TypeCometChatChangeScopeOptionData[]
Defaultundefined
Required.
interface CometChatChangeScopeOptionData {
  id: string;
  label: string;
}

defaultSelection

The id of the initially selected scope option. The submit button stays disabled until the user selects a different option.
Typestring
Default''

onScopeChanged

Called when the user clicks the submit button. Receives the selected scope id. Return a Promise — the component shows a loading spinner while it resolves and displays an error if it rejects.
Type(scopeId: string) => Promise<void>
Defaultundefined

onClose

Called when the user clicks cancel or presses Escape. Also called automatically after a successful onScopeChanged resolution.
Type() => void
Defaultundefined

className

Custom CSS class appended to the root container.
Typestring
Defaultundefined

children

Content rendered inside the dialog. Typically Header, ScopeList, ErrorMessage, and Actions sub-components.
TypeReactNode
Defaultundefined

CometChatChangeScope.Header

title

Title text displayed in the header. Defaults to the localized “Change Scope” string.
Typestring
DefaultLocalized "Change Scope"

description

Description text below the title. Defaults to the localized subtitle.
Typestring
DefaultLocalized subtitle

showIcon

Whether to display the scope icon above the title.
Typeboolean
Defaulttrue

className

Custom CSS class appended to the header container.
Typestring
Defaultundefined

CometChatChangeScope.ScopeList

className

Custom CSS class appended to the radio group container.
Typestring
Defaultundefined

children

The ScopeOption sub-components to render.
TypeReactNode
Defaultundefined

CometChatChangeScope.ScopeOption

option

The scope option data object.
TypeCometChatChangeScopeOptionData
Defaultundefined
Required.

className

Custom CSS class appended to the option row.
Typestring
Defaultundefined

CometChatChangeScope.Actions

submitText

Text for the submit button. Defaults to the localized “Save” string.
Typestring
DefaultLocalized "Save"

cancelText

Text for the cancel button. Defaults to the localized “Cancel” string.
Typestring
DefaultLocalized "Cancel"

className

Custom CSS class appended to the button container.
Typestring
Defaultundefined

CometChatChangeScope.ErrorMessage

className

Custom CSS class appended to the error message container.
Typestring
Defaultundefined

CSS Selectors

TargetSelector
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