# ChatWindow

> Props, styling and a live ChatWindow example.

`ChatWindow` from `@polymorfa/react`. Choose props and styles above; the preview stays visible in every code view.

## Props

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `composerController` | `MessageComposerController` | Optional |  | Renders the built-in composer. Omit it for read-only history. |
| `composerProps` | `Omit<ComposeBoxProps, "controller" \| "createController" \| "conversation">` | Optional |  | Props for the built-in composer, except its controllers. |
| `header` | `ReactNode` | Optional |  | Content above the messages. |
| `footer` | `ReactNode` | Optional |  | Content below the composer. |
| `disabled` | `boolean` | Optional | `false` | Read-only until the host confirms sending is available. |
| `className` | `string` | Optional |  | Same as `MessageList`. |
| `classNames` | `SlotClassNames` | Optional |  | Same as `MessageList`. |
| `controller` | `ConversationController` | Optional |  | Conversation to render. |
| `createController` | `() => ConversationController` | Optional |  | Factory for a controller the component owns. |
| `messageFilter` | `(message: ConversationMessage) => boolean` | Optional |  | Presentation-only: never reloads history or cancels a send. |
| `renderMessage` | `(message: ConversationMessage) => ReactNode` | Optional |  | Same as `MessageList`. |
| `renderAttachment` | `RenderAttachment` | Optional |  | Same as `MessageList`. |
| `onReply` | `(message: ConversationMessage) => void` | Optional |  | Show a Reply action on each message. |

## composerProps

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `onSent` | `() => void` | Optional |  | Called after a send. |
| `className` | `string` | Optional |  | Class for the root. |
| `classNames` | `SlotClassNames` | Optional |  | Classes keyed by slot. |
| `attachments` | `boolean` | Optional | `true` | Offer file attachments: the attach button, drop and paste. Defaults to `true`. Turn it off when the composer's actions have no upload adapter. |
| `accept` | `string` | Optional |  | File types the attach button offers, as for `<input accept>`. |
| `attachmentKinds` | `readonly AttachmentKind[]` | Optional |  | Offer named file types. Omit to keep the single file picker. |
| `multiple` | `boolean` | Optional | `true` | Allow picking several files at once. Defaults to `true`. |
| `messages` | `readonly ConversationMessage[]` | Optional |  | Resolves the reply banner's quoted message without a controller. |
| `placeholder` | `string` | Optional | Locale text | Replaces the locale's `composer.placeholder`. |
| `startActions` | `ReactNode` | Optional |  | Rendered in the toolbar before the built-in buttons. |
| `endActions` | `ReactNode` | Optional |  | Rendered after the message field, before the send or mic button. |
| `emoji` | `boolean` | Optional | `true` | Show the emoji picker button. Defaults to `true`. |
| `voiceNotes` | `boolean` | Optional | `true` where supported | Show the voice note button. Defaults to `true` where the browser has `MediaRecorder` and `getUserMedia`. |
| `voiceNoteAutoSend` | `boolean` | Optional | `true` | Send a voice note as soon as it finishes uploading. Defaults to `true`. |
| `quickReplies` | `readonly QuickReplyOption[]` | Optional |  | Options for the "/" quick reply menu. |
| `onQuickReply` | `(option: QuickReplyOption) => void` | Optional |  | Called after a quick reply's text is inserted. |
| `maxRows` | `number` | Optional | `8` | Rows the message field grows to before it scrolls. Defaults to 8. |

## Types

Named types used in the props above.

```ts @polymorfa/ui
type AttachmentKind =
  | "image"
  | "video"
  | "audio"
  | "document";
```

```ts @polymorfa/react
type RenderAttachment = (attachment: MessageAttachment, message: ConversationMessage) => ReactNode;
```

## Styling

Use `className`, `classNames` (a class for any [slot](https://docs.polymorfa.com/ui-kit/appearance#slots), typed `SlotClassNames`), appearance variables and element styles. The Style panel applies changes to the live component. See [Appearance](https://docs.polymorfa.com/ui-kit/appearance).

## Setup

Use [the provider and server route](https://docs.polymorfa.com/ui-kit/setup) for your application. The preview above uses local sample data and controllers. [Chat controllers](https://docs.polymorfa.com/ui-kit/chat#controllers) and [inbox data sources](https://docs.polymorfa.com/ui-kit/inbox#data-sources) keep your data separate from the UI.
