# composerSend

> Wires a composer's send control: Enter sends, Shift+Enter writes a new line, the field clears once a message goes, and a reply the page just answered replays as a stream that Stop or Escape freezes.

```ts
import { composerSend } from "@sdxc/ui/chat";
```

Put on an element inside a composer's form, around its send and stop buttons. It finds the
form's `Composer.Input`, and a click on a `[data-slot="composer-stop"]` inside it stops the
replay.

## Signature

```ts
composerSend(options: ComposerSendOptions): MixinDescriptor<HTMLElement>
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `ComposerSendOptions` |  |

## Examples

```tsx
<span mix={[composerSend({ stream: "reply-7", onStreamingChange: (on) => … })]}>…</span>
```

## Used with it

The events, constants and types its module publishes, each imported from `@sdxc/ui/chat` too.

### COMPOSER_STOP_SLOT

The slot of the button that stops a streaming reply, inside the mixin's host.

#### Signature

```ts
const COMPOSER_STOP_SLOT = "composer-stop"
```

### ComposerSendOptions

Options for composerSend.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `stream?` | `string` | The `id` of a reply the page just answered with, marked `data-stream-pending`; it replays as a stream, or shows at once under reduced motion. |
| `streamKey?` | `string` | Changes with every new reply, so a reply that reuses the previous one's `id` replays too. |
| `onStreamingChange` | `(streaming: boolean) => void` | Told when a replay starts and ends, so the host can swap Send for Stop. |
