> ## 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.

# File Bubble

> A self-extracting bubble that renders a file attachment with its name, size, type icon, and a download action.

<Accordion title="AI Integration Quick Reference">
  ```json theme={null}
  {
    "component": "CometChatFileBubble",
    "package": "@cometchat/chat-uikit-react",
    "import": "import { CometChatFileBubble } from \"@cometchat/chat-uikit-react\";",
    "description": "Self-extracting file bubble. Extracts the file attachment (url, name, size, extension) and caption from a MediaMessage.",
    "cssRootClass": ".cometchat-file-bubble",
    "selfExtracting": true,
    "props": {
      "data": {
        "message": { "type": "CometChat.MediaMessage", "required": true, "note": "Drives extraction of the file attachment and caption." },
        "alignment": { "type": "\"left\" | \"right\"", "note": "Defaults to sender-vs-logged-in-user." },
        "textFormatters": { "type": "CometChatTextFormatter[]" },
        "className": { "type": "string" }
      }
    }
  }
  ```
</Accordion>

## Overview

`CometChatFileBubble` renders a file attachment. It is **self-extracting**: pass the SDK `message` and the bubble derives the file's URL, name, size, and extension (plus any caption) itself, so it works standalone. It shows a type icon, the file name and size, and a download control.

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

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

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

***

## Usage

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

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

***

## Props

### message

The file message. The bubble extracts the attachment (url, name, size, extension) and caption from it. **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 applied to the extracted caption.

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

***

### className

Additional CSS class applied to the root element.

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

***

## CSS Selectors

| Target            | Selector                                                              |
| ----------------- | --------------------------------------------------------------------- |
| Root              | `.cometchat-file-bubble`                                              |
| Sender / receiver | `.cometchat-file-bubble--sender` / `.cometchat-file-bubble--receiver` |
| Type icon         | `.cometchat-file-bubble__icon`                                        |
| File name         | `.cometchat-file-bubble__filename`                                    |
| File size         | `.cometchat-file-bubble__filesize`                                    |
| Download          | `.cometchat-file-bubble__download`                                    |
| Caption           | `.cometchat-file-bubble__caption`                                     |

***

## Next Steps

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

  <Card title="Audio Bubble" icon="microphone" href="/ui-kit/react/components/audio-bubble">
    Render audio 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>
