diff --git a/docusaurus/docs/React/components/contexts/message-input-context.mdx b/docusaurus/docs/React/components/contexts/message-input-context.mdx
index 2cfc44b4f8..3d44caddb2 100644
--- a/docusaurus/docs/React/components/contexts/message-input-context.mdx
+++ b/docusaurus/docs/React/components/contexts/message-input-context.mdx
@@ -250,7 +250,7 @@ Function that runs onSubmit to the underlying `textarea` component.
Allows to hide MessageInput's send button. Used by `MessageSimple` to hide the send button in `EditMessageForm`. Received from `MessageInputProps`.
| Type | Default |
-|---------|---------|
+| ------- | ------- |
| boolean | false |
### imageOrder
@@ -438,6 +438,28 @@ If true, triggers typing events on text input keystroke.
| ------- | ------- |
| boolean | true |
+### removeAttachments
+
+Function to remove an attachment objects from the `attachments` array in the `MessageInputState`.
+
+| Type |
+| ---------------------- |
+| (id: string[]) => void |
+
+```jsx
+const Component = () => {
+ const { attachments, removeAttachments } = useMessageInputContext();
+
+ return (
+
+ {attachments.map((att) => (
+
+ ))}
+
+ );
+};
+```
+
### removeFile
Function to remove a file from the `fileUploads` mapping.
@@ -526,6 +548,33 @@ Function to upload an array of files to the `fileUploads` and `imageUploads` map
| ----------------------------------- |
| (files: FileList \| File[]) => void |
+### upsertAttachments
+
+Function that adds or updates `attachments` array in `MessageInputState`. Accepts an array of objects.
+
+| Type |
+| -------------------------------------------------------------------------------------------------- |
+| `(attachments: (Attachment \| LocalAttachment)[]) => void` |
+
+```jsx
+const Component = () => {
+ const { upsertAttachments } = useMessageInputContext();
+
+ const handleSelect = (location) => {
+ upsertAttachments([
+ {
+ type: 'geolocation',
+ longitude: location.longitude,
+ latitude: location.latitude,
+ name: location.name,
+ },
+ ]);
+ };
+
+ // ...
+};
+```
+
### useMentionsTransliteration
If true, will use an optional dependency to support transliteration in the input for mentions. See: https://github.com/sindresorhus/transliterate
diff --git a/docusaurus/docs/React/components/message-input-components/ui-components.mdx b/docusaurus/docs/React/components/message-input-components/ui-components.mdx
index 10129bc661..4a4a1437e3 100644
--- a/docusaurus/docs/React/components/message-input-components/ui-components.mdx
+++ b/docusaurus/docs/React/components/message-input-components/ui-components.mdx
@@ -26,8 +26,8 @@ The following UI components are available for use:
- [`SendButton`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/icons.tsx) - on click, sends a
message to the currently active channel
-- [`UploadsPreview`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/UploadsPreview.tsx) - displays
- a list of uploaded files prior to sending the message
+- [`AttachmentPreviewList`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx) - displays
+ a list of message attachments
## ChatAutoComplete Props
@@ -155,8 +155,46 @@ Function to send a message to the currently active channel.
| ----------------------------------------- |
| (event: React.BaseSyntheticEvent) => void |
-## UploadsPreview
+## AttachmentPreviewList
-:::note
-`UploadsPreview` only consumes context and does not accept any optional props.
-:::
+Renders message attachments in preview. The default (supported) message attachment types are:
+
+- `audio`
+- `video`
+- `image`
+- `voiceRecording`
+- `file`
+
+If the attachment object has property `og_scrape_url` or `title_link`, then it is rendered be [`LinkPreviewList` component](#linkpreviewlist-props) and not `AttachmentPreviewList`.
+
+### FileAttachmentPreview
+
+Custom component to be rendered for attachments of types `'file'`, `'video'`, `'audio'`.
+
+| Type |
+| ------------------------------------------- |
+| `ComponentType` |
+
+### ImageAttachmentPreview
+
+Custom component to be rendered for uploaded `'image'` attachment.
+
+| Type |
+| -------------------------------------------- |
+| `ComponentType` |
+
+### UnsupportedAttachmentPreview
+
+Custom component to be rendered for attachment that is not recognized as any of the default types.
+
+| Type |
+| -------------------------------------------------- |
+| `ComponentType` |
+
+### VoiceRecordingPreview
+
+Custom component to preview audio recorded using [`AudioRecorder` component](../audio_recorder).
+
+| Type |
+| ------------------------------------------- |
+| `ComponentType` |
diff --git a/docusaurus/docs/React/guides/message-input/attachment-previews.mdx b/docusaurus/docs/React/guides/message-input/attachment-previews.mdx
new file mode 100644
index 0000000000..22c34d747f
--- /dev/null
+++ b/docusaurus/docs/React/guides/message-input/attachment-previews.mdx
@@ -0,0 +1,75 @@
+---
+id: attachment_previews
+title: Attachment Previews in Message Input
+---
+
+In this section we will focus on how to customize attachment previews display in `MessageInput` component. The attachment previews are rendered by [`AttachmentPreviewList` component](../../../components/message-input-components/ui_components#attachmentpreviewlist).
+
+## Customize the rendering of default attachment previews
+
+The default attachment types recognized by `AttachmentPreviewList` are:
+
+- `audio`
+- `video`
+- `image`
+- `voiceRecording`
+- `file`
+
+If the attachment object has property `og_scrape_url` or `title_link`, then it is rendered by [`LinkPreviewList` component](#linkpreviewlist-props) and not `AttachmentPreviewList`.
+
+To customize attachment previews we need to override `AttachmentsPreviewList` component.
+
+```jsx
+import { VideoAttachmentPreview } from './AttachmentPreviews';
+
+const CustomAttachmentPreviewList = () => (
+
+);
+```
+
+And pass it to `Channel` component.
+
+```jsx
+
+```
+
+We can customize the following preview components:
+
+- `AudioAttachmentPreview`
+- `FileAttachmentPreview`
+- `ImageAttachmentPreview`
+- `UnsupportedAttachmentPreview`
+- `VideoAttachmentPreview`
+- `VoiceRecordingPreview`
+
+## Customize the rendering of custom attachment previews
+
+It is possible to add custom attachments (objects) to composed messages via [`upsertAttachments` function](../../../components/contexts/message-input-context#upsertattachments) provided by `MessageInputContext`.
+
+The custom attachments are not recognized by `AttachmentPreviewList` component and therefore rendered via `UnsupportedAttachmentPreview` component within `AttachmentPreviewList`. The component `UnsupportedAttachmentPreview` can be customized and handle all the custom attachment objects added to the message attachments.
+
+```tsx
+import { GeolocationPreview } from './GeolocationAttachmentPreview';
+import type { UnsupportedAttachmentPreviewProps } from 'stream-chat-react';
+
+const CustomAttachmentsPreview = (props: UnsupportedAttachmentPreviewProps) => {
+ const { attachment } = props;
+ if (attachment.type === 'geolocation') {
+ return ;
+ }
+ // more conditions follow...
+};
+```
+
+The custom component is then passed to custom `AttachmentsPreviewList` component which purpose is just to specify the custom `UnsupportedAttachmentPreview` component.
+
+```jsx
+import { CustomAttachmentsPreview } from './AttachmentPreviewList';
+const CustomAttachmentPreviewList = () => (
+
+);
+```
+
+```jsx
+
+```
diff --git a/docusaurus/sidebars-react.json b/docusaurus/sidebars-react.json
index 8f084dc97b..99d1787f33 100644
--- a/docusaurus/sidebars-react.json
+++ b/docusaurus/sidebars-react.json
@@ -110,6 +110,7 @@
"Message Input": [
"guides/theming/input_ui",
"guides/customization/link-previews",
+ "guides/message-input/attachment_previews",
"guides/customization/override_submit_handler",
"guides/customization/persist_input_text_in_localstorage",
"guides/customization/suggestion_list",
diff --git a/package.json b/package.json
index b3e9dc6df4..d492402e59 100644
--- a/package.json
+++ b/package.json
@@ -148,7 +148,7 @@
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@stream-io/rollup-plugin-node-builtins": "^2.1.5",
- "@stream-io/stream-chat-css": "^4.14.0",
+ "@stream-io/stream-chat-css": "^4.16.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^13.1.1",
"@testing-library/react-hooks": "^8.0.0",
diff --git a/src/components/Attachment/AttachmentContainer.tsx b/src/components/Attachment/AttachmentContainer.tsx
index 0f559f16b1..c895da4686 100644
--- a/src/components/Attachment/AttachmentContainer.tsx
+++ b/src/components/Attachment/AttachmentContainer.tsx
@@ -10,7 +10,7 @@ import { VoiceRecording as DefaultVoiceRecording } from './VoiceRecording';
import { Gallery as DefaultGallery, ImageComponent as DefaultImage } from '../Gallery';
import { Card as DefaultCard } from './Card';
import { FileAttachment as DefaultFile } from './FileAttachment';
-import { NullComponent as DefaultUnsupportedAttachment } from './UnsupportedAttachment';
+import { UnsupportedAttachment as DefaultUnsupportedAttachment } from './UnsupportedAttachment';
import {
AttachmentContainerProps,
isGalleryAttachmentType,
diff --git a/src/components/Attachment/UnsupportedAttachment.tsx b/src/components/Attachment/UnsupportedAttachment.tsx
index af46b4897f..dfcc4b6a83 100644
--- a/src/components/Attachment/UnsupportedAttachment.tsx
+++ b/src/components/Attachment/UnsupportedAttachment.tsx
@@ -1,4 +1,6 @@
import React from 'react';
+import { FileIcon } from '../ReactFileUtilities';
+import { useTranslationContext } from '../../context';
import type { Attachment } from 'stream-chat';
import type { DefaultStreamChatGenerics } from '../../types/types';
@@ -12,13 +14,21 @@ export const UnsupportedAttachment = <
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
>({
attachment,
-}: UnsupportedAttachmentProps) => (
-