Composer

The prompt box: grows with what is written, then scrolls; Send, which becomes Stop while a response streams.

View source
A response is arriving; stop it to send this prompt.
import { Composer } from "@logicplanes/kaeso-ui/playground";

Props

  • accept
    string

    The file types the Attach button offers, as an accept attribute (image/*,application/pdf).

  • actions
    ReactNode

    Controls at the start of the button row: parameters, clear. Ghost and secondary buttons there take tones made for the composer's surface.

  • aria-label
    string

    The text box's accessible name ("Prompt" by default).

  • attachLabel
    string

    The Attach button's name and tooltip ("Attach files" by default).

  • attachments
    readonly Attachment[] = []

    Files waiting to go with the prompt, drawn above the text box; with any, Send works without text.

  • autoFocus
    boolean

    Focuses the composer when it appears.

  • clearOnSubmit
    boolean = true

    Clears an uncontrolled composer after Send (true by default).

  • defaultValue
    string

    The message on first render.

  • disabled
    boolean = false

    Turns it off: it can't be used, and it looks dimmed.

  • loading
    boolean = false

    The prompt is being sent: Send shows a spinner.

  • maxRows
    number = 10

    Lines before the text box scrolls (10 by default).

  • name
    string

    The field name the value is sent under in a form.

  • onAttach
    ((files: File[]) => void)

    Takes files: an Attach button at the start of the button row, files dropped anywhere on the composer (its outline darkens while they hover) and files pasted into the text box. Check their type and size here and say what was refused.

  • onRemoveAttachment
    ((id: string) => void)

    Removes a waiting file by its id.

  • onStop
    (() => void)

    Stop: the button while streaming.

  • onSubmit
    ((value: string) => void)

    Send: the Send button, Enter in the text box (see submitOn), or ⌘ Enter (Ctrl Enter). Not called for a prompt that is empty or only spaces, while disabled, sending or streaming, or while an input method is composing.

  • onValueChange
    ((value: string) => void)

    Called with the message as it is typed.

  • placeholder
    string

    Text shown while there is no value.

  • size
    "md" | "sm" = md

    The composer's height.

  • stopLabel
    string

    The Stop button's name and tooltip, while a response streams ("Stop" by default).

  • streaming
    boolean = false

    A response is arriving: Send becomes Stop. The text box stays editable for the next prompt; Enter waits, and the text box's description says to stop the response to send.

  • submitLabel
    string

    The Send button's name and tooltip ("Send" by default).

  • submitOn
    "enter" | "mod-enter" = enter

    The key that sends from the text box. "enter" (default): Enter sends and Shift Enter adds a line; on a touch screen Enter adds a line and the Send button sends. "mod-enter": Enter adds a line and only ⌘ Enter (Ctrl Enter) sends. ⌘ Enter and Ctrl Enter send with either.

  • value
    string

    The message being written, when you control it.