> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Bubble

> A self-extracting bubble that renders one or more image attachments with grid layouts, a caption, and a fullscreen viewer.

<Accordion title="AI Integration Quick Reference">
  ```json theme={null}
  {
    "component": "CometChatImageBubble",
    "package": "@cometchat/chat-uikit-react",
    "import": "import { CometChatImageBubble } from \"@cometchat/chat-uikit-react\";",
    "description": "Self-extracting image bubble. Extracts image attachments and caption from a MediaMessage; supports single/grid layouts and a fullscreen viewer.",
    "cssRootClass": ".cometchat-image-bubble",
    "selfExtracting": true,
    "props": {
      "data": {
        "message": { "type": "CometChat.MediaMessage", "required": true, "note": "Drives extraction of attachments and caption." },
        "alignment": { "type": "\"left\" | \"right\"", "note": "Defaults to sender-vs-logged-in-user." },
        "textFormatters": { "type": "CometChatTextFormatter[]" },
        "placeholderImage": { "type": "string" },
        "onImageClicked": { "type": "(attachment, index) => void" },
        "className": { "type": "string" }
      }
    }
  }
  ```
</Accordion>

## Overview

`CometChatImageBubble` renders the image attachment(s) of a media message. It is **self-extracting**: pass the SDK `message` and the bubble derives its attachments, caption, and alignment itself, so it works standalone.

It supports multiple images with automatic layouts (single, grid, 2×2, and an overflow tile for extra images) and opens a fullscreen viewer when an image is clicked.

<Info>
  **Live Preview** — interact with the image bubble.

  [Open in Storybook ↗](https://storybook.cometchat.io/react/?path=/story/components-bubbles-message-bubble-image--default)
</Info>

<iframe src="https://storybook.cometchat.io/react/iframe.html?id=components-bubbles-message-bubble-image--default&viewMode=story&shortcuts=false&singleStory=true" className="w-full rounded-xl" loading="lazy" style={{height: "600px", border: "1px solid #e0e0e0"}} title="CometChat Image Bubble — Default" allow="clipboard-write" />

***

## Usage

```tsx theme={null}
import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatImageBubble } from "@cometchat/chat-uikit-react";

function ImageMessage({ message }: { message: CometChat.MediaMessage }) {
  return <CometChatImageBubble message={message} />;
}
```

***

## Props

### message

The image message. The bubble extracts its attachments and caption. **Required.**

|          |                          |
| -------- | ------------------------ |
| Type     | `CometChat.MediaMessage` |
| Required | Yes                      |

***

### alignment

Override incoming/outgoing alignment. Defaults to sender-vs-logged-in-user.

|         |                     |
| ------- | ------------------- |
| Type    | `"left" \| "right"` |
| Default | derived             |

***

### textFormatters

Text formatters for caption rendering (mentions, URLs).

|         |                            |
| ------- | -------------------------- |
| Type    | `CometChatTextFormatter[]` |
| Default | `undefined`                |

***

### placeholderImage

Custom placeholder image URL shown while the image loads. Falls back to a default photo icon.

|         |             |
| ------- | ----------- |
| Type    | `string`    |
| Default | `undefined` |

***

### onImageClicked

Fires when an image is clicked (in addition to opening the fullscreen viewer).

|         |                                                                       |
| ------- | --------------------------------------------------------------------- |
| Type    | `(attachment: CometChatImageBubbleAttachment, index: number) => void` |
| Default | `undefined`                                                           |

***

### className

Additional CSS class applied to the root element.

|         |             |
| ------- | ----------- |
| Type    | `string`    |
| Default | `undefined` |

***

## CSS Selectors

| Target              | Selector                                                                  |
| ------------------- | ------------------------------------------------------------------------- |
| Root                | `.cometchat-image-bubble`                                                 |
| Incoming / outgoing | `.cometchat-image-bubble--incoming` / `.cometchat-image-bubble--outgoing` |
| Single image        | `.cometchat-image-bubble--single`                                         |
| Container           | `.cometchat-image-bubble__container`                                      |
| Grid                | `.cometchat-image-bubble__grid`                                           |
| Image               | `.cometchat-image-bubble__image`                                          |
| Overflow overlay    | `.cometchat-image-bubble__overflow-overlay`                               |
| Placeholder         | `.cometchat-image-bubble__placeholder`                                    |
| Caption             | `.cometchat-image-bubble__caption`                                        |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Image Plugin" icon="image" href="/ui-kit/react/plugins/overview#built-in-plugins">
    Plugin behavior, context menu, and conversation preview
  </Card>

  <Card title="Video Bubble" icon="video" href="/ui-kit/react/components/video-bubble">
    Render video attachments
  </Card>

  <Card title="Message Bubble" icon="comment" href="/ui-kit/react/components/message-bubble">
    The wrapper that hosts bubble content
  </Card>

  <Card title="Theming" icon="paintbrush" href="/ui-kit/react/theming">
    Customize colors, fonts, and spacing
  </Card>
</CardGroup>
