Composer
The prompt box: grows with what is written, then scrolls; Send, which becomes Stop while a response streams.
function Basic() {
const [streaming, setStreaming] = useState(false);
return (
<Composer
className="w-full max-w-640"
streaming={streaming}
onSubmit={() => {
setStreaming(true);
setTimeout(() => setStreaming(false), 2400);
}}
onStop={() => setStreaming(false)}
/>
);
}import { Composer } from "@logicplanes/kaeso-ui/playground";Props
acceptstringThe file types the Attach button offers, as an
acceptattribute (image/*,application/pdf).actionsReactNodeControls at the start of the button row: parameters, clear. Ghost and secondary buttons there take tones made for the composer's surface.
aria-labelstringThe text box's accessible name ("Prompt" by default).
attachLabelstringThe Attach button's name and tooltip ("Attach files" by default).
attachmentsreadonly Attachment[] = []Files waiting to go with the prompt, drawn above the text box; with any, Send works without text.
autoFocusbooleanFocuses the composer when it appears.
clearOnSubmitboolean = trueClears an uncontrolled composer after Send (true by default).
defaultValuestringThe message on first render.
disabledboolean = falseTurns it off: it can't be used, and it looks dimmed.
loadingboolean = falseThe prompt is being sent: Send shows a spinner.
maxRowsnumber = 10Lines before the text box scrolls (10 by default).
namestringThe 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.
placeholderstringText shown while there is no value.
size"md" | "sm" = mdThe composer's height.
stopLabelstringThe Stop button's name and tooltip, while a response streams ("Stop" by default).
streamingboolean = falseA 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.
submitLabelstringThe Send button's name and tooltip ("Send" by default).
submitOn"enter" | "mod-enter" = enterThe 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.valuestringThe message being written, when you control it.