> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-agent-in-group-react-v6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Groups

> Groups — CometChat documentation.

This component lists all the groups created on CometChat and also allows users to search for groups. It enables users to find and locate specific groups based on various search criteria or parameters.

## Properties

### Title

Heading text for the component

| Name           | Type   | Description                                     |
| -------------- | ------ | ----------------------------------------------- |
| title          | string | Heading text for the component                  |
| titleAlignment | string | Alignment of the heading text for the component |

### Search

This involves keywords, phrases, or criteria into the search bar and retrieving relevant results based on the search query.

| Name              | Type    | Description                                                            |
| ----------------- | ------- | ---------------------------------------------------------------------- |
| searchPlaceholder | string  | Sample text that appears in the search input as a prompt or suggestion |
| searchIconURL     | string  | Asset URL for the search icon.                                         |
| hideSearch        | boolean | When set to true, hides the search input.                              |

### Loading state

This refers to the state of the groups component when it is actively retrieving or fetching data.

| Name             | Type   | Description                                               |
| ---------------- | ------ | --------------------------------------------------------- |
| loadingIconURL   | string | Asset URL for the loading indicator icon                  |
| loadingStateView | view   | User-defined component to customise the loading indicator |

### Empty state

This refers to the state of the groups component when it has no content or data to display

| Name           | Type   | Description                                                           |
| -------------- | ------ | --------------------------------------------------------------------- |
| emptyStateText | string | The textual content displayed in the empty state of the component.    |
| emptyStateView | view   | User-defined component to customise the empty state of the component. |

### Error state

This refers to the state of the groups component when an error occurs during the retrieval of the data.

| Name           | Type   | Description                                                           |
| -------------- | ------ | --------------------------------------------------------------------- |
| errorStateText | string | The textual content displayed in the error state of the component.    |
| errorStateView | view   | User-defined component to customise the error state of the component. |

### RequestBuilder

This provides set of methods that allow developers to easily create and configure groups before fetching them for the intended recipients.

| Name                 | Type                                                                                      | Description                                                                                                         |
| -------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| searchRequestBuilder | [CometChat.GroupsRequestBuilder](/sdk/javascript/retrieve-groups#retrieve-list-of-groups) | Class that allows you to set various parameters to the `GroupsRequest` class based on which the groups are searched |
| groupsRequestBuilder | [CometChat.GroupsRequestBuilder](/sdk/javascript/retrieve-groups#retrieve-list-of-groups) | Class that allows you to set various parameters to the `GroupsRequest` class based on which the groups are fetched  |

### Toggle

Switch to hide or show the separators, and error message.

| Name          | Type    | Description                                                                        |
| ------------- | ------- | ---------------------------------------------------------------------------------- |
| hideError     | boolean | When set to true, hides the error messages displayed within the component          |
| hideSeparator | boolean | When set to true, hides the separator between the individual elements in the list. |

### activeGroup

This refers to a group which has an ongoing interactions and participation from its members.

| Name        | Type            | Description                                                   |
| ----------- | --------------- | ------------------------------------------------------------- |
| activeGroup | CometChat.Group | Group where where members are actively engaged in discussions |

### selectionMode

Allows user to choose individual or multiple items.

| Name          | Type                                                       | Description                                                                          |
| ------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| selectionMode | [SelectionMode](/web-shared/selectionmode)                 | Allows user to select individual or multiple items for applying specific operations. |
| onSelect      | Function as PropType\<(groups:CometChat.Group\[]) => void> | Method invoked which returns the selected groups.                                    |

### Custom view

UI component created and customised by the developer to meet your design or functional requirements.

| Name         | Type                                                        | Description                                                                                |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| subtitleView | Function as PropType\<(group: CometChat.Group) => ViewType> | User-defined component to customise the secondary text shown in the default group profile. |

### Menu

UI component created and customised by the developer to meet your design or functional requirements representing the button actions in the header section.

| Name | Type | Description                                                                             |
| ---- | ---- | --------------------------------------------------------------------------------------- |
| menu | view | User-defined component to showcase options related to the groups in the header section. |

### Actions

This includes action buttons or icons that allow users to perform common actions or tasks, such as muting the notification etc.

| Name    | Type                                                                                       | Description                                                     |
| ------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
| options | Function as PropType\<(group:CometChat.Group) => [CometChatOption](/web-shared/option)\[]> | User-defined actions which appears for each group on mouseover. |

### Function Callback

Functions that can be invoked by the user in response to a specific event or condition.

| Name        | Type                                                                 | Description                                                                           |
| ----------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| onItemClick | Function as PropType\<(group:CometChat.Group) => void>               | Override the method that is invoked when user clicks on a individual item in the list |
| onError     | Function as PropType\<(error: CometChat.CometChatException) => void> | Override the method that is invoked when an error is encountered within the component |

### Style

Styling properties and values of all the involved components

| Name                 | Type                                                   | Description                                                                                      |
| -------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
| avatarStyle          | [AvatarStyle](/web-elements/avatar#avatar-style)       | Styling properties and values of the [Avatar](/web-elements/avatar) component                    |
| statusIndicatorStyle | [StatusIndicator](/web-elements/status-indicator)      | Styling properties and values of the [StatusIndicator](/web-elements/status-indicator) component |
| listItemStyle        | [ListItemStyle](/web-elements/list-item#listitemstyle) | Styling properties and values of the [ListItem](/web-elements/list-item) component               |
| groupsStyle          | [GroupsStyle](/web-shared/groupsstyle)                 | Styling properties and values of the [Groups](/ui-kit/vue/groups) component                      |

## Usage

CometChatGroups can be launched by adding the following code snippet.

<Tabs>
  <Tab title="Vue">
    ```js theme={null}
    const getSubtitleView = (group:CometChat.Group) => {
      return {
        html: `<p>${group.getGuid()}</p>`,
      };
    };

    const getEmptyStateView = () => {
      return {
      	html: "<p>CustomEmptyView</p>",
      };
    };

    const getLoadingStateView = () => {
      return {
      	componentName: "CustomLoadingViewComponent",
      };
    };

    const getErrorStateView = () => {
      return {
      	componentName: "CustomErrorViewComponent",
      };
    };

    let emptyStateText = "groups not found";
    let errorStateText = "somet thing went wrong";
    let DeleteIcon = "./assets/DeleteIcon.svg";

    function options(group: CometChat.Group) {

      return [
        new CometChatOption({
        	id: "id",
        	title: "Delete user",
        	iconURL: DeleteIcon,
        	iconTint: "blue",
        	onClick: () => //do something,
        }),
      ];
    }

    <CometChatGroups
      :subtitleView="getSubtitleView"
      :emptyStateText="emptyStateText"
      :errorStateText="errorStateText"
      :emptyStateView="getEmptyStateView"
      :loadingStateView="getLoadingStateView"
      :errorStateView="errorStateView"
      :options="options"></CometChatGroups>
    ```
  </Tab>
</Tabs>
