You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
State representing the array of loaded channels. Channels query is executed by default only within the [`ChannelList` component](../core-components/channel-list.mdx) in the SDK.
Copy file name to clipboardExpand all lines: docusaurus/docs/React/components/utility-components/avatar.mdx
+51-19Lines changed: 51 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,44 +3,64 @@ id: avatar
3
3
title: Avatar
4
4
---
5
5
6
-
The `Avatar` component displays an image, with fallback to the first letter of the optional name prop.
6
+
Semantically we can speak about two types of avatars in the SDK. One type is the avatar that represents the channel and the other representing another user. The SDK exports the follwing avatar components:
7
7
8
-
## Basic Usage
8
+
-`Avatar` - displays single image or name initials in case image is not available
9
+
-`GroupAvatar` - displays images or name initials as a fallback in a 2x2 grid
10
+
-`ChannelAvatar` - renders `GroupAvatar` in case a channel has more than two members and `Avatar` otherwise
9
11
10
-
A typical use case for the `Avatar` component would be to import and use in your custom components that will completely override a header component, preview component, or similar.
12
+
By default, all the SDK components use `Avatar` to display channel resp. user avatar. However, it makes sense to override the default in `ChannelList` resp. `ChannelPreview` and `ChannelHeader` as those avatars may represent a group of users .
13
+
14
+
## Customizing avatar component
15
+
16
+
Passing your custom avatar component to `Channel` prop `Avatar` overrides the avatar for all the `Channel` component's children.
11
17
12
18
Here's an example of using the `Avatar` component within a custom preview component:
You can also take advantage of the `Avatar` prop on the `ChannelHeader` and `ChannelList` components to override just that aspect of these components specifically, see the example below.
32
34
33
-
An example of overriding just the `Avatar` component in the default `ChannelPreviewMessenger` component.
35
+
An example of overriding just the `Avatar` component in the default `ChannelPreview` component.
/** UI component to display a user's avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
16
-
Avatar?: React.ComponentType<AvatarProps>;
15
+
/** UI component to display an avatar, defaults to [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) component and accepts the same props as: [ChannelAvatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/ChannelAvatar.tsx) */
16
+
Avatar?: React.ComponentType<ChannelAvatarProps>;
17
17
/** Manually set the image to render, defaults to the Channel image */
18
18
image?: string;
19
19
/** Show a little indicator that the Channel is live right now */
0 commit comments