ZAO造

Composer

A compact raised writing tray for a request, its context, and local attachments.

Preview

Su uses the Quiet instrument direction. Use the mode switcher above to see light and dark.

With context

  • Project files
  • Reference data

Enter adds a line. Ctrl or Cmd + Enter sends.

Empty draft

Enter adds a line. Ctrl or Cmd + Enter sends.

Disabled

Enter adds a line. Ctrl or Cmd + Enter sends.

Send error

Enter adds a line. Ctrl or Cmd + Enter sends.

Usage

  • Keep the draft controlled. The host accepts requests, clears accepted drafts, processes uploads, and owns the response lifecycle.
  • Start with a compact one-line draft. Enter adds a line; Cmd or Ctrl + Enter and the Send control share a guarded submission path. The writing plane grows to eight lines, then scrolls.
  • Keep one square, stationary tray: a border-subtle perimeter and border-default lower contact edge frame the clear writing plane. Only focus within the textarea strengthens the contact edge to border-strong; toolbar focus keeps the tray at rest.
  • Supply context and named attachments before the writing plane. File selection and previews are local; accept and validation belong to the product.
  • Use filled bg-sunken ComposerContextChip tags in the context slot for supplied context. An optional decorative SVG component, such as an Iconoir icon, indicates its type. The host removes context through onRemove; removal returns focus to the draft without sending or changing its contents.
  • Use the icon-only toolbar for Attach files, Send, and Stop response. The larger plus drawing aligns with the draft and chips; inset spacing gives its 28px target room within the tray. Keep the next draft editable during a response. Stop asks the host to stop; keep responding true until the host confirms the outcome. Pending controls block repeated requests without adding a caption row.
  • Preserve failed drafts and explain how to retry. onSend can return a promise; Composer catches failures and blocks duplicate sends while it is pending.

API

PropValuesDefault
labelstring; visually hidden accessible namerequired
value / onValueChangecontrolled string / (value) => voidrequired
onSend(draft: ComposerDraft) => void | Promise<void>required
responding / onStopboolean / () => void | Promise<void>; host confirms stoppingfalse / —
attachmentsreadonly { id: string; file: File }[][]
onFilesSelect / onRemoveAttachment(files: File[]) => void / (id: string) => void—
accept / multiplenative file types / booleanall types / true
context / actionsReact content—
ComposerContextChip label / onRemovestring / () => void; native div props and refrequired
ComposerContextChip iconIconButtonIcon; optional decorative SVG component—
disabled / errorboolean / correction guidancefalse / —
textareaPropsuncontrolled native attributes and events—

Example

import { Composer, ComposerContextChip } from '@zao/react';
import { Database } from 'iconoir-react';

<Composer
  label="Request"
  value={draft}
  onValueChange={setDraft}
  onSend={acceptRequest}
  responding={responding}
  onStop={stopResponse}
  context={snapshotIncluded ? (
    <ComposerContextChip
      label="Storage snapshot"
      icon={Database}
      onRemove={() => setSnapshotIncluded(false)}
    />
  ) : undefined}
/>

Accessibility

Composer uses a native form and textarea with a visually hidden, required label. Pointer clicks keep the writing plane unframed; keyboard entry retains a visible focus outline. Textarea focus strengthens only the tray’s contact edge. Error and keyboard guidance are associated with the input. IME composition never sends. IconButtons, including context removal, provide accessible names, visible focus, and hover or focus tooltips. Optional context icons are hidden from assistive technology; labels name the context. Filenames stay complete in the accessibility tree; compact file tiles fit keyboard and touch use.