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

# Contacts

> Contacts — CometChat documentation.

`CometChatContacts` is a `UIViewController` specifically designed to facilitate the display and management of users and groups within chat applications. It streamlines the process of showcasing all app users and available chat groups in a user-friendly interface, making it easier for users to connect and communicate effectively. Additionally, the view controller includes a `UISegmentedControl` to switch between the users and groups list, enhancing navigation and usability.

Key Features:

1. **User List View**: CometChatContacts presents a comprehensive list of all registered users within the application. This list allows users to quickly find and select specific individuals they wish to interact with.
2. **Group List View**: The component also offers a dedicated view to showcase all the available chat groups. This simplifies the process of joining or creating new group conversations.
3. **Smart Search Functionality**: Users can utilize the powerful search feature to quickly locate specific users or groups by typing names or keywords. This ensures seamless navigation, even in applications with a large user base.
4. **Selection Mode**: CometChatContacts supports a selection mode, enabling users to pick multiple contacts or groups simultaneously. This feature proves useful for creating group chats or forwarding messages to multiple recipients.
5. **Customizable Tab Layout**: Developers can easily customize the appearance of the tabs, including text colors, indicator color, and background, to match the app's branding and aesthetics.
6. **Selection Limit Control**: Developers have the flexibility to set a selection limit, restricting the number of contacts or groups a user can select during the selection mode. This helps maintain messaging policies and optimize user experience.
7. **User-Friendly Close Button**: The component provides a convenient close button feature, allowing users to exit the Contacts view and return to their previous screen or chat interface effortlessly.

## How to integrate CometChatContacts

CometChatContacts can launched on to a new screen using the following code snippet.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    self.present(UINavigationController(rootViewController: CometChatContacts()), animated: true)
    ```
  </Tab>
</Tabs>

## Methods

| Methods | Parameters | Description |
| - | - | - |
| **title** | String | Sets the title that will be displayed at the top of the `CometChatContacts` view. This method allows you to customize the title to provide relevant information or context to the users. |
| **usersTabTitle** | String | `usersTabTitle` is used to set the users tab title for the `CometChatContacts` Component |
| **groupsTabTitle** | String | `groupsTabTitle` is used to set the groups tab title for the `CometChatContacts` Component. |
| **usersConfiguration** | UsersConfiguration | `usersConfiguration` is used to set the configurations for the CometChatUsers Component embedded in `CometChatContacts` Component. |
| **groupsConfiguration** | GroupsConfiguration | `groupsConfiguration` is used to set the configurations for the CometChatGroups Component embedded in `CometChatContacts` Component. |
| **onItemTap** | (\_ controller: UIViewController?, user: User?, group: Group?) -> Void | `onItemTap` is used to set the action to be performed when a user or group is tapped. |
| **closeIcon** | UIImage | `closeIcon` is used to set the close icon. |
| | | |
| **onClose** | () -> Void | `onClose` is used to set the action to be performed when close icon is tapped. |
| **submitIcon** | UIImage | `submitIcon` is used to set the submit icon |
| | | |
| **onSubmitIconTap** | (\_ selectedUsers: \[User]? , \_ selectedGroups: \[Group]?) -> Void | `onSubmitIconTap` is used to set the action to be performed when submit icon is tapped |
| **hideSubmitButton** | Bool | `hideSubmitButton` is used to hide the submit button in CometChatContacts Component. |
| **selectionLimit** | Int | `selectionLimit` is used to set the selection limit for the CometChatUsers and CometChatGroups subviews embedded inside CometChatContacts. |
| **selectionMode** | SelectionMode | `selectionMode` is used to set the selection mode for the CometChatUsers and CometChatGroups subviews embedded inside CometChatContacts. |
| **contactsStyle** | ContactsStyle | the property `contactsStyle` is used to set the style for the `CometChatContacts` Component. |
| **tabVisibility** | TabVisibility | the property `tabVisibility` is used to set the tab visibility for the CometChatContacts Component. Default value is usersAndGroups. |

## ContactsStyle

This property is used to customize the appearance of the CometChatContacts component.

| Methods | Parameter | Description |
| - | - | - |
| **titleTextColor** | UIColor | used to set the text color of the title |
| **titleTextFont** | UIFont | used to set the text font of the title |
| **tabTitleTextColor** | UIColor | is used to set the tab title text color |
| **tabTitleTextFont** | UIFont | used to set the tab title text font |
| **tabWidth** | CGFloat | used to set the tab width |
| **tabHeight** | CGFloat | used to set the tab height |
| **activeTabTitleTextColor** | UIColor | used to set the active tab title text color |
| **activeTabBackground** | UIColor | used to set the active tab background color |
| **closeIconTint** | UIColor | used to set the close icon tint color |
| **selectionIconTint** | UIColor | used to set the selection icon tint color |
| **errorStateTextColor** | UIColor | used to set the error state text color |
| **errorStateTextFont** | UIFont | used to set the error state text font |
| **submitButtonBackground** | UIColor | used to set the submit button background color |
| **submitButtonTextColor** | UIColor | used to set the submit button text color |
| **submitButtonTextFont** | UIFont | used to set the submit button text font |
| **tableViewStyle** | UITableView\.Style | used to set the tableView style, default value is insetGrouped |

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let contacts = CometChatContacts()
    let contactsStyle = ContactsStyle()
    contactsStyle
            .set(activeTabBackground: UIColor(red: 0.00, green: 0.48, blue: 1.00, alpha: 1.00))
            .set(activeTabTitleTextColor: .white)
            .set(background: .white)
            .set(borderColor: UIColor(red: 0.78, green: 0.78, blue: 0.80, alpha: 1.00))
            .set(borderWidth: 1)
            .set(closeIconTint: UIColor(red: 0.00, green: 0.48, blue: 1.00, alpha: 1.00))
            .set(errorStateTextColor: UIColor(red: 0.00, green: 0.48, blue: 1.00, alpha: 1.00))
            .set(errorStateTextFont: UIFont.systemFont(ofSize: 16))
            .set(selectionIconTint: UIColor(red: 0.00, green: 0.48, blue: 1.00, alpha: 1.00))
            .set(submitButtonTextColor: .blue)
            .set(submitButtonBackground: .white)
            .set(submitButtonTextFont: UIFont.systemFont(ofSize: 16))

    contacts.setContactsStyle(contactsStyle: contactsStyle)

    let naviVC = UINavigationController(rootViewController: contacts)

    self.present(naviVC, animated: true)
    ```

    <Tip>
      If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
    </Tip>
  </Tab>
</Tabs>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.