AI Chat Fancy Stable

Composer

.md

The input at the bottom of a chat, taken apart: a root that owns the draft and eight parts that read it — a growing textarea, a send button that becomes a stop button, a toolbar, a model picker, an attachment row with its chips, and a completion menu you can mount twice on the same draft for / commands and @ mentions

Preview

Installation

pnpm add fancy-ui-svelte
import { Composer } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Composer } from 'fancy-ui-svelte';
</script>

<Composer />

Examples

Basic Usage

Full Composer

Props

PropTypeDefaultDescription
value string""The draft text, bindable. Cleared by a successful submit; the attachments are not, since only the consumer knows whether an upload is still in flight
attachments AttachmentData[][]Files riding along with the draft, bindable. The consumer owns uploading them and pushing the results here
disabled booleanfalseBlocks typing, sending, and attaching. Every part reads it off the context, so one flag takes the whole composition inert
streaming booleanfalseA response is arriving: the send button becomes a stop button, the textarea goes readonly rather than disabled, and a submit is refused whatever triggered it
placeholder string-Placeholder for the default input. Ignored once children replaces the composition — the ComposerInput inside it carries its own
onSubmit (payload: { text: string; attachments: AttachmentData[] }) => void-Called with the trimmed draft and a snapshot of the attachments. Never fires on an empty draft that carries no files
onStop () => void-Called when the stop button is pressed while streaming
onAttach (files: File[]) => void-Called with the files handed to the picker. Upload them, then push the results onto attachments — the composer never uploads anything itself
sound booleanfalsePlays press on send and stop, select on a model or command pick and open/close on the model menu, once the user has enabled sound

Slots

SlotDescription
childrenReplaces the default input-and-send-row composition entirely: mount the parts in whatever order the layout needs
accessoryAn overlay covering the composer — a voice panel, a drop target, a confirmation. It sits above the composition rather than replacing it, so the draft is still there when it lifts