# Chat Attachments (/docs/components/chat-attachments)



<ComponentPreview name="chat-attachment" />

## Installation [#installation]

<Tabs items="[&#x22;Command&#x22;, &#x22;Manual&#x22;]">
  <Tab value="Command">
    <CodeBlockTabs defaultValue="npm">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="npm">
          npm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="pnpm">
          pnpm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="yarn">
          yarn
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="bun">
          bun
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="npm">
        ```bash
        npx shadcn@latest add @uploadcn/chat-attachments
        ```
      </CodeBlockTab>

      <CodeBlockTab value="pnpm">
        ```bash
        pnpm dlx shadcn@latest add @uploadcn/chat-attachments
        ```
      </CodeBlockTab>

      <CodeBlockTab value="yarn">
        ```bash
        yarn dlx shadcn@latest add @uploadcn/chat-attachments
        ```
      </CodeBlockTab>

      <CodeBlockTab value="bun">
        ```bash
        bun x shadcn@latest add @uploadcn/chat-attachments
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Tab>

  <Tab value="Manual">
    Install [Upload](/docs/components/upload) first, then copy:

    <ComponentSource name="chat-attachments" />
  </Tab>
</Tabs>

## Usage [#usage]

```tsx
import { ChatAttachments } from "@/components/chat-attachments"
```

```tsx
<ChatAttachments
  onSend={async ({ text, attachments }) => {
    await sendMessage({ text, files: attachments.map((item) => item.result) })
  }}
/>
```

Images are downscaled to 1568px WebP before upload (the size vision models work with), which makes attachments upload several times faster. Paste is scoped to the composer.

## Props [#props]

<TypeTable
  type="{
  adapter: {
    type: &#x22;UploadAdapter&#x22;,
    default: 's3Adapter({ endpoint: &#x22;/api/upload&#x22; })',
    description: &#x22;Where files go.&#x22;,
  },
  onSend: {
    type: &#x22;({ text, attachments }) => void | Promise<void>&#x22;,
    description: &#x22;Called on Enter or the send button, once uploads finished.&#x22;,
  },
  placeholder: { type: &#x22;string&#x22; },
  accept: {
    type: &#x22;string[]&#x22;,
    default: &#x22;images, PDF, text, Markdown, CSV, JSON, DOCX&#x22;,
  },
  maxFiles: { type: &#x22;number&#x22;, default: &#x22;10&#x22; },
  maxSize: { type: &#x22;number&#x22;, default: &#x22;25 MB&#x22; },
  disabled: { type: &#x22;boolean&#x22; },
}"
/>
