# Composer

Source: https://ecosphere.dev/docs/forms/composer (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Reply composer with attach and split send.

`import { EcoComposer } from "vue-ecosphere"`

## Composer

Write something and press Send (or Ctrl/⌘+Enter). The chevron schedules it.

Vue (vue-ecosphere):

```vue
<EcoComposer v-model="reply" :when="when"
  @send="(text) => sent.push(text)"
  @attach="openFilePicker"
  @schedule="when = 'Sends tomorrow at 09:00'" />
```

React (react-ecosphere):

```tsx
const [reply, setReply] = useState("");
const [sent, setSent] = useState<string[]>([]);
const [when, setWhen] = useState<string>();

<EcoComposer value={reply} onChange={setReply} when={when}
  onSend={(text) => setSent((s) => [...s, text])}
  onAttach={openFilePicker}
  onSchedule={() => setWhen("Sends tomorrow at 09:00")} />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model` | `string` | "" | The draft. Send stays disabled while it is blank. |
| `placeholder / label` | `string` | "Write your reply" / "Your reply" | Placeholder and accessible name of the textarea. |
| `when` | `string` | — | Scheduled send time shown in cwhen. |
| `attachable / schedulable` | `boolean` | true | Show the attach button / the schedule chevron. |
| `scheduleOpen` | `boolean` | false | aria-expanded on the chevron while your schedule menu is open. |
| `clearOnSend` | `boolean` | true | Empty the draft after send. |
| `sendLabel / attachLabel / scheduleLabel` | `string` | — | Button text and names. |
| `disabled` | `boolean` | false | Disable the whole composer. |
| `@send` | `(text: string) => void` | — | Send, or Ctrl/⌘+Enter. |
| `@attach / @schedule` | `() => void` | — | Attach button / schedule chevron. |
| `#top / #tools / #schedule` | `slot` | — | Above the textarea / start of the toolbar / after the send button (for a menu). |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value / onChange` | `string` | "" | The draft. Send stays disabled while it is blank. |
| `placeholder / label` | `string` | "Write your reply" / "Your reply" | Placeholder and accessible name of the textarea. |
| `when` | `string` | — | Scheduled send time shown in cwhen. |
| `attachable / schedulable` | `boolean` | true | Show the attach button / the schedule chevron. |
| `scheduleOpen` | `boolean` | false | aria-expanded on the chevron while your schedule menu is open. |
| `clearOnSend` | `boolean` | true | Empty the draft after send. |
| `sendLabel / attachLabel / scheduleLabel` | `string` | — | Button text and names. |
| `disabled` | `boolean` | false | Disable the whole composer. |
| `onSend` | `(text: string) => void` | — | Send, or Ctrl/⌘+Enter. |
| `onAttach / onSchedule` | `() => void` | — | Attach button / schedule chevron. |
| `top / tools / schedule` | `ReactNode` | — | Above the textarea / start of the toolbar / after the send button (for a menu). |
