Gallery

Renders image attachments inside MessageList.

Best Practices

  • Keep gallery layouts compact to avoid oversized rows.
  • Use setOverlay and gallery context helpers instead of custom image viewers.
  • Handle mixed image/video attachments gracefully.
  • Respect preventPress when you need to disable full-screen viewing.
  • Avoid heavy image processing in render; rely on caching or native components.

Basic Usage

Replace the default UI via WithComponents.

import { WithComponents, Gallery } from "stream-chat-react-native";

<WithComponents overrides={{ Gallery: () => <Gallery preventPress /> }}>
  <Channel channel={channel}>
    <MessageList />
    <MessageComposer />
  </Channel>
</WithComponents>;

Props

PropDescriptionType
additionalPressablePropsExtra props passed to the underlying Pressable used in message components like MessageContent.object
alignmentSets whether the message aligns left or right in the list. Defaults to 'right'.enum('right', 'left')
groupStylesPosition of the message within a group of consecutive messages from the same user. Use groupStyles to style messages based on position (for example, avatars show only on the last message).array of enum('top', 'bottom', 'middle', 'single')
hasThreadRepliesWhether the current message has thread replies. Used to set the correct bottom corner radius based on alignment. Defaults to !!message.reply_count.boolean
imagesArray of image attachments on the message.array
legacyImageViewerSwipeBehaviourEnable/disable legacy image viewer behavior. When true, the image viewer lets you swipe through all loaded images in the channel, adding JS thread work. Available in SDK version >= v3.9.0. Defaults to false.boolean
messageIdID of the current message.string
messageTextText content of the current message (message.text). Used for gallery styling.string
onLongPressDefault long press handler for message UI.function
onPressDefault press handler for message UI.function
onPressInDefault pressIn handler for message UI.function
preventPressIf true, disables onPress. Defaults to false.boolean
setSelectedMessageSetter for value selectedMessage.(selectedMessage: {messageId?: string; url?: string;}) => void
setMessagesSetter for value messages.(messages: LocalMessage[]) => void
setOverlaySetter for overlay. You can use this setter to show the overlay.(overlay) => void
threadListTrue if the current message is part of a thread.boolean
videosArray of video attachments.array

UI Component Props

PropDescriptionType
VideoThumbnailRenders video thumbnails for video attachments in MessageList. Defaults to VideoThumbnail.ComponentType