Skip to main content
The CometChatUsers component displays a searchable list of all available users. It shows user names, avatars, and online/offline status indicators. Users can be filtered, searched, and selected for starting conversations.
CometChatUsers showing a searchable list of users with avatars, names, and online/offline status indicators

Where It Fits

CometChatUsers displays all available users for starting new conversations. It’s typically used as a standalone screen or within a tab view controller.
CometChatUsers displaying the user list within a navigation controller hierarchy

Minimal Render

CometChatUsers showing the minimal render with default configuration

Filtering

Use UsersRequest.UsersRequestBuilder to filter which users appear in the list. The builder pattern allows chaining multiple filter conditions.

Filter Recipes


Actions and Events

Callback Props

onItemClick

Fires when a user taps on a user in the list. Use this to start a conversation.

onItemLongClick

Fires when a user long-presses on a user. Use this to show additional options.

onBack

Fires when the back button is pressed.

onSelection

Fires when users are selected in selection mode.

onError

Fires when an error occurs while loading users.

onEmpty

Fires when the user list is empty.

onLoad

Fires when users are successfully loaded. The callback receives a nested array where each inner array represents a section of users (grouped alphabetically).

Actions Reference

Global UI Events

SDK Events (Real-Time, Automatic)


Custom View Slots

listItemView

Replace the entire user row with a custom design.

leadingView

Customize the leading view (avatar area) of a user cell.
CometChatUsers with custom leadingView showing user avatars with a star badge overlay
You can create a CustomLeadingView as a custom UIView:

titleView

Customize the title view of a user cell.
CometChatUsers with custom titleView showing user names with a green Teacher badge
You can create a CustomTitleView as a custom UIView:

subtitleView

Customize the subtitle area below the user name.
CometChatUsers with custom subtitleView showing last active timestamp below user names
You can create a CustomSubtitleView as a custom UIView:

trailingView

Customize the trailing view (right side) of a user cell.
CometChatUsers with custom trailingView showing a purple PRO badge with star icon
You can create a CustomTrailView as a custom UIView:

loadingStateView

Customize the loading state view displayed while data is being fetched.

errorStateView

Customize the error state view displayed when an error occurs.

emptyStateView

Customize the empty state view displayed when no users are available.

Methods

Swipe Action Methods

set(options:)

Sets custom swipe actions for user list items, replacing the default options. These options appear when the user swipes on a user cell.

add(options:)

Adds additional swipe actions to the existing default options.

Data Manipulation Methods

add(user:)

Adds a new user to the user list.

update(user:)

Updates an existing user in the list.

remove(user:)

Removes a user from the list.

getSelectedUsers()

Returns an array of currently selected users when in selection mode.

Custom ListItem

For more complex or unique list items, you can create a custom UIView file named CustomListItem and integrate it into the set(listItemView:) method.
CometChatUsers with custom listItemView showing a simplified user row with avatar and name
Usage:

Styling

Style Hierarchy

  1. Global styles (CometChatUsers.style) apply to all instances
  2. Instance styles override global for specific instances

Global Level Styling

Instance Level Styling

CometChatUsers with custom styling showing modified background colors and text appearance

Key Style Properties

Customization Matrix


Props

All props are optional. Sorted alphabetically.

avatarStyle

Customizes the appearance of avatars in user list items.

hideBackButton

Hides the back button in the navigation bar.

hideErrorView

Hides the error state view.

hideLoadingState

Hides the loading state indicator.

hideNavigationBar

Hides the entire navigation bar.

hideSearch

Hides the search bar.

hideSectionHeader

Hides the alphabetical section headers.

hideUserStatus

Hides online/offline status indicators.

onSelectedItemProceed

Callback triggered when the user confirms their selection in selection mode. Use this to handle the selected users.

searchRequestBuilder

Custom request builder for search functionality.

selectedCellCount

Returns the count of currently selected users in selection mode.

selectionLimit

Sets the maximum number of users that can be selected in selection mode. When the limit is reached, further selections are disabled.

selectionMode

Sets the selection mode for multi-select functionality.

statusIndicatorStyle

Customizes the appearance of online/offline status indicators.

usersRequestBuilder

Custom request builder for filtering users.

Events


Common Patterns

Friends-only list

Online users only

Custom empty state with CTA

Hide all chrome — minimal list

Multi-select users