> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# State Views

> Replace or hide the loading, empty and error views of CometChat iOS UI Kit v6 components in SwiftUI and UIKit.

Components show a state view while data loads, when there is nothing to show, and when a fetch
fails. Replace any of them with your own view, or hide them.

***

## State Types

| State | When it shows |
| - | - |
| Loading | the first page is being fetched — a shimmer by default |
| Empty | the fetch returned nothing |
| Error | the fetch failed — with a retry by default |

***

## Replacing State Views

> [tab] SwiftUI
>
> Each component takes `loadingView`, `emptyView` and `errorView` closures returning
> `AnyView`. `errorView` receives a `retry` closure — call it to fetch again:
>
> ```swift theme={null}
> CometChatConversations(
>     loadingView: { AnyView(ProgressView().controlSize(.large)) },
>     emptyView: {
>         AnyView(
>             VStack(spacing: 12) {
>                 Image(systemName: "bubble.left.and.bubble.right")
>                     .font(.system(size: 56))
>                     .foregroundStyle(.secondary)
>                 Text("No conversations yet").font(.title3)
>             }
>         )
>     },
>     errorView: { retry in
>         AnyView(
>             VStack(spacing: 8) {
>                 Text("Something went wrong")
>                 Button("Retry", action: retry)
>             }
>         )
>     }
> )
> ```
>
> The same three are modifiers that reach every instance below them, for example
> `.cometChatConversationEmptyView { … }`. The argument wins over the modifier.

> [tab] UIKit
>
> Each list takes a `UIView` for each state:
>
> ```swift theme={null}
> let empty = UILabel()
> empty.text = "No conversations yet"
> empty.textAlignment = .center
> empty.textColor = CometChatUIKitTheme.shared.textSecondary
>
> let spinner = UIActivityIndicatorView(style: .large)
> spinner.startAnimating()
>
> conversations
>     .set(loadingView: spinner)
>     .set(emptyView: empty)
>     .set(errorView: MyErrorState())
> ```
>
> Set them before the screen appears. Afterwards, call `renderCurrentState()` so the screen
> redraws its current state with the new view.

![Conversations list showing a custom loading view](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-loadingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=64924fdc83ef0bb79d0f874d38d5e8fe)

loadingView

![Conversations list showing a custom empty state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-emptyView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=b5ea7cce2b5d91c821166daaee66a906)

emptyView

![Conversations list showing a custom error state with a retry button](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-errorView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=cc0b7243346f62bcfbc30805e5c91628)

errorView

![UIKit Conversations showing a custom loading view](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-loadingView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=14d20bdf123a7754e34a39b6076a36ec)

UIKit loadingView

![UIKit Conversations showing a custom empty state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-emptyView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=cc6a7f48b780e1bb97d9e1a20b173c72)

UIKit emptyView

![UIKit Conversations showing a custom error state](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/uikit-errorView.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=81a58eb539de84bba3a3348cf22f8327)

UIKit errorView

***

## Restyle Instead of Replacing

To keep the built-in views and change only their colours and fonts, use the component's style.

> [tab] SwiftUI
>
> ```swift theme={null}
> var style = CometChatGroupsStyle()
> style.retryButtonCornerRadius = 20
> style.loadingStateSurfaceColor = .gray.opacity(0.2)
> CometChatGroups(style: style)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let style = MessageListStyle()
> style.emptyStateTitleColor = .secondaryLabel
> style.errorStateTitleFont = .preferredFont(forTextStyle: .headline)
> messageList.style = style
> ```

***

## Hiding State Views

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatConversations(
>     hideLoadingState: true,
>     hideEmptyState: true,
>     hideErrorState: true
> )
>
> CometChatMessageList(
>     user: user,
>     hideLoadingState: true,
>     hideEmptyState: true,
>     hideErrorState: true
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> conversations
>     .set(hideLoadingState: true)
>     .set(hideEmptyState: true)
>     .set(hideErrorState: true)
>
> messageList.hideErrorView = true
> ```
>
> Every list also has `hideLoadingState` and `hideErrorView` properties.

***

## Components with State Views

> [tab] SwiftUI
>
> | Component | States | Modifiers |
> | - | - | - |
> | `CometChatConversations` | Loading, Empty, Error | `cometChatConversationLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatUsers` | Loading, Empty, Error | `cometChatUserLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatGroups` | Loading, Empty, Error | `cometChatGroupsLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatGroupMembers` | Loading, Empty, Error | `cometChatGroupMembersLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatCallLogs` | Loading, Empty, Error | `cometChatCallLogsLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatMessageList` | Loading, Empty, Error | `cometChatMessageListLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatSavedMessages` | Loading, Empty, Error | `cometChatSavedMessagesLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatStickerKeyboard` | Loading, Empty, Error | `cometChatStickerKeyboardLoadingView`, `…EmptyView`, `…ErrorView` |
> | `CometChatReactionList` | Loading, Error | `cometChatReactionListLoadingView`, `…ErrorView` |
> | `CometChatSearch`, `CometChatPinnedMessages` | Loading, Empty, Error | arguments only |

> [tab] UIKit
>
> | Component | States |
> | - | - |
> | `CometChatConversations`, `CometChatUsers`, `CometChatGroups`, `CometChatGroupMembers` | Loading, Empty, Error |
> | `CometChatCallLogs`, `CometChatSearch`, `CometChatPinnedMessages`, `CometChatSavedMessages` | Loading, Empty, Error |
> | `CometChatMessageList` | Loading, Empty, Error |
>
> All take `set(loadingView:)`, `set(emptyView:)` and `set(errorView:)`.

***

## Related

* [View Slots](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-view-slots.md) — replace regions of a row.
* [Customization Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/customization-overview.md) — every customization category.


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